From 5729cd163328fc6b53e5db84662ffc06dd6a9bd1 Mon Sep 17 00:00:00 2001 From: 杨张扬 <634643841@qq.com> Date: 星期三, 14 五月 2025 17:30:36 +0800 Subject: [PATCH] 同步-双钱-单独的新的版本库 --- .vs/HH.WCS.Mobox3.DoubleCoin/FileContentIndex/8d42b6c2-185a-4930-92d0-0bff37fd654e.vsidx | 0 models/TN_Location.cs | 60 device/S7Helper.cs | 423 ++ swagger.js | 110 models/TN_CG_Detail.cs | 47 models/TN_Container.cs | 13 wms/WMSHelper.cs | 127 api/ApiModel.cs | 448 ++ .vs/HH.WCS.Langchao/FileContentIndex/read.lock | 0 .vs/HH.WCS.Langchao/FileContentIndex/4a385bfe-ecd2-4870-b27e-b29514f713d2.vsidx | 0 device/ScanCodeHelper.cs | 95 device/OpcUaHelper.cs | 193 .editorconfig | 7 .vs/HH.WCS.JunzhouLangchao/FileContentIndex/b5d4cc0d-d072-4a06-b41d-eed5482c7ae2.vsidx | 0 api/AgvController.cs | 35 models/BaseModel.cs | 25 models/TN_SPOT_DATEIL.cs | 42 HH.WCS.Mobox3.DoubleCoin.sln | 30 .vs/HH.WCS.JunzhouLangchao/FileContentIndex/read.lock | 0 wms/ContainerHelper.cs | 141 models/TN_WorkOrder.cs | 20 process/TaskProcess.cs | 217 + App_Start/Startup.cs | 48 models/TN_Task_Action.cs | 19 wms/SYSHelper.cs | 43 models/TN_CAR_IN.cs | 20 process/DeviceProcess.cs | 62 Properties/AssemblyInfo.cs | 36 .vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.backup.json | 12 models/TN_TN_SPE.cs | 31 dispatch/NDCHelper.cs | 81 util/LogHelper.cs | 144 models/TN_Component_Detail.cs | 78 util/Settings.cs | 170 api/ApiHelper.cs | 1662 ++++++++ App_Start/SwaggerControllerDescProvider.cs | 82 models/TN_InventoryM.cs | 61 .vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.json | 37 config/configDesc.txt | 60 models/TN_WeekProDetail.cs | 27 Program.cs | 172 .vs/HH.WCS.Langchao/FileContentIndex/64fc2de3-4821-4c46-8f63-3c1f84a578ce.vsidx | 0 core/Monitor.cs | 792 +++ models/TN_YearProDetail.cs | 27 config/config.json | 46 dispatch/HanAo.cs | 164 App_Start/SwaggerConfig.cs | 255 + models/TN_MonthProDetail.cs | 27 wms/WCSHelper.cs | 250 + device/TcpClient.cs | 85 device/TcpServer.cs | 277 + packages.config | 53 dispatch/NDC.cs | 164 models/TN_RemeltDetail.cs | 71 models/TN_EquipProDetail.cs | 76 core/WMSCore.cs | 15 .vs/HH.WCS.Mobox3.Template.csproj.dtbcache.json | 1 dispatch/NDCApi.cs | 271 + models/TN_Loc_Container.cs | 23 device/ModbusHelper.cs | 426 ++ wms/LocationHelper.cs | 606 +++ dispatch/HostToAGV.cs | 550 ++ readme.txt | 1 device/PlcHelper.cs | 99 models/TN_DayProDetail.cs | 27 models/TN_Task.cs | 60 core/WCSCore.cs | 681 +++ models/TN_Operator_info.cs | 36 api/WmsController.cs | 20 util/SqlHelper.cs | 71 api/DebugController.cs | 111 util/HttpHelper.cs | 286 + wms/SpecHelper.cs | 389 + .vs/HH.WCS.Langchao/FileContentIndex/095323c9-fab1-4a3d-bbb9-e016bdc026ba.vsidx | 0 dispatch/GZRobot.cs | 395 + App.config | 74 .vs/HH.WCS.Mobox3.WeiLi/FileContentIndex/57367193-8890-401b-95eb-fa75f34fc9b1.vsidx | 0 models/TN_SPOT_CHECK.cs | 58 api/MoboxController.cs | 214 + HH.WCS.Mobox3.DoubleCoin.csproj | 305 + models/TN_SurplusDetail.cs | 71 81 files changed, 11,955 insertions(+), 0 deletions(-) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a8b9d36 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +锘縖*.cs] + +# Default severity for all analyzer diagnostics +dotnet_analyzer_diagnostic.severity = none + +# CS1591: 缂哄皯瀵瑰叕鍏卞彲瑙佺被鍨嬫垨鎴愬憳鐨�XML 娉ㄩ噴 +dotnet_diagnostic.CS1591.severity = none diff --git a/.vs/HH.WCS.JunzhouLangchao/FileContentIndex/b5d4cc0d-d072-4a06-b41d-eed5482c7ae2.vsidx b/.vs/HH.WCS.JunzhouLangchao/FileContentIndex/b5d4cc0d-d072-4a06-b41d-eed5482c7ae2.vsidx new file mode 100644 index 0000000..05edd6d --- /dev/null +++ b/.vs/HH.WCS.JunzhouLangchao/FileContentIndex/b5d4cc0d-d072-4a06-b41d-eed5482c7ae2.vsidx Binary files differ diff --git a/.vs/HH.WCS.JunzhouLangchao/FileContentIndex/read.lock b/.vs/HH.WCS.JunzhouLangchao/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.vs/HH.WCS.JunzhouLangchao/FileContentIndex/read.lock diff --git a/.vs/HH.WCS.Langchao/FileContentIndex/095323c9-fab1-4a3d-bbb9-e016bdc026ba.vsidx b/.vs/HH.WCS.Langchao/FileContentIndex/095323c9-fab1-4a3d-bbb9-e016bdc026ba.vsidx new file mode 100644 index 0000000..71c525f --- /dev/null +++ b/.vs/HH.WCS.Langchao/FileContentIndex/095323c9-fab1-4a3d-bbb9-e016bdc026ba.vsidx Binary files differ diff --git a/.vs/HH.WCS.Langchao/FileContentIndex/4a385bfe-ecd2-4870-b27e-b29514f713d2.vsidx b/.vs/HH.WCS.Langchao/FileContentIndex/4a385bfe-ecd2-4870-b27e-b29514f713d2.vsidx new file mode 100644 index 0000000..621de9e --- /dev/null +++ b/.vs/HH.WCS.Langchao/FileContentIndex/4a385bfe-ecd2-4870-b27e-b29514f713d2.vsidx Binary files differ diff --git a/.vs/HH.WCS.Langchao/FileContentIndex/64fc2de3-4821-4c46-8f63-3c1f84a578ce.vsidx b/.vs/HH.WCS.Langchao/FileContentIndex/64fc2de3-4821-4c46-8f63-3c1f84a578ce.vsidx new file mode 100644 index 0000000..42ed048 --- /dev/null +++ b/.vs/HH.WCS.Langchao/FileContentIndex/64fc2de3-4821-4c46-8f63-3c1f84a578ce.vsidx Binary files differ diff --git a/.vs/HH.WCS.Langchao/FileContentIndex/read.lock b/.vs/HH.WCS.Langchao/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/.vs/HH.WCS.Langchao/FileContentIndex/read.lock diff --git a/.vs/HH.WCS.Mobox3.DoubleCoin/FileContentIndex/8d42b6c2-185a-4930-92d0-0bff37fd654e.vsidx b/.vs/HH.WCS.Mobox3.DoubleCoin/FileContentIndex/8d42b6c2-185a-4930-92d0-0bff37fd654e.vsidx new file mode 100644 index 0000000..fdcf17d --- /dev/null +++ b/.vs/HH.WCS.Mobox3.DoubleCoin/FileContentIndex/8d42b6c2-185a-4930-92d0-0bff37fd654e.vsidx Binary files differ diff --git a/.vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.backup.json b/.vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.backup.json new file mode 100644 index 0000000..6f0ea6e --- /dev/null +++ b/.vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.backup.json @@ -0,0 +1,12 @@ +{ + "Version": 1, + "WorkspaceRootPath": "E:\\004-HanHe\\01-Program\\DoubleCoin\\HH.WCS.Mobox3.DoubleCoin\\", + "Documents": [], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [] + } + ] +} \ No newline at end of file diff --git a/.vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.json b/.vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.json new file mode 100644 index 0000000..68b4ead --- /dev/null +++ b/.vs/HH.WCS.Mobox3.DoubleCoin/v17/DocumentLayout.json @@ -0,0 +1,37 @@ +{ + "Version": 1, + "WorkspaceRootPath": "E:\\004-HanHe\\01-Program\\DoubleCoin\\HH.WCS.Mobox3.DoubleCoin\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}|HH.WCS.Mobox3.DoubleCoin.csproj|e:\\004-hanhe\\01-program\\doublecoin\\hh.wcs.mobox3.doublecoin\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}|HH.WCS.Mobox3.DoubleCoin.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 0, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "Program.cs", + "DocumentMoniker": "E:\\004-HanHe\\01-Program\\DoubleCoin\\HH.WCS.Mobox3.DoubleCoin\\Program.cs", + "RelativeDocumentMoniker": "Program.cs", + "ToolTip": "E:\\004-HanHe\\01-Program\\DoubleCoin\\HH.WCS.Mobox3.DoubleCoin\\Program.cs", + "RelativeToolTip": "Program.cs", + "ViewState": "AgIAAIQAAAAAAAAAAAAqwJMAAAA1AAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-05-06T05:45:19.684Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/.vs/HH.WCS.Mobox3.Template.csproj.dtbcache.json b/.vs/HH.WCS.Mobox3.Template.csproj.dtbcache.json new file mode 100644 index 0000000..e552514 --- /dev/null +++ b/.vs/HH.WCS.Mobox3.Template.csproj.dtbcache.json @@ -0,0 +1 @@ +{"RootPath":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\HH.WCS.Mobox3.Template","ProjectFileName":"HH.WCS.Mobox3.Template.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"api\\MoboxController.cs"},{"SourceFile":"api\\AgvController.cs"},{"SourceFile":"api\\ApiModel.cs"},{"SourceFile":"core\\WMSCore.cs"},{"SourceFile":"device\\ModbusHelper.cs"},{"SourceFile":"device\\PlcHelper.cs"},{"SourceFile":"device\\TcpClient.cs"},{"SourceFile":"device\\TcpServer.cs"},{"SourceFile":"dispatch\\GZRobot.cs"},{"SourceFile":"dispatch\\NDC.cs"},{"SourceFile":"core\\Monitor.cs"},{"SourceFile":"models\\BaseModel.cs"},{"SourceFile":"models\\Area.cs"},{"SourceFile":"models\\TN_ASN_Detail.cs"},{"SourceFile":"models\\TN_ASN_Order.cs"},{"SourceFile":"models\\TN_AZ_Inventory.cs"},{"SourceFile":"models\\TN_Business_Source.cs"},{"SourceFile":"models\\CntrItemRel.cs"},{"SourceFile":"models\\TN_Check_Detail.cs"},{"SourceFile":"models\\TN_Check_List.cs"},{"SourceFile":"models\\TN_Check_Order.cs"},{"SourceFile":"models\\Container.cs"},{"SourceFile":"models\\TN_Container_Good.cs"},{"SourceFile":"models\\TN_Equipment.cs"},{"SourceFile":"models\\TN_Factory.cs"},{"SourceFile":"models\\TN_Function_Area.cs"},{"SourceFile":"models\\TN_Inspect_Detail.cs"},{"SourceFile":"models\\TN_Inspect_Order.cs"},{"SourceFile":"models\\TN_Inspect_Record.cs"},{"SourceFile":"models\\TN_LC_Log.cs"},{"SourceFile":"models\\Location.cs"},{"SourceFile":"models\\TN_Lock.cs"},{"SourceFile":"models\\LocCntrRel.cs"},{"SourceFile":"models\\TN_Loc_EQ_Link.cs"},{"SourceFile":"models\\TN_Material.cs"},{"SourceFile":"models\\TN_MQ_EQAction.cs"},{"SourceFile":"models\\TN_MQ_EQAction_Msg.cs"},{"SourceFile":"models\\TN_OnOff_Shelves.cs"},{"SourceFile":"models\\TN_OOS_Detail.cs"},{"SourceFile":"models\\TN_OOS_Order.cs"},{"SourceFile":"models\\WMSTask.cs"},{"SourceFile":"models\\TN_Outbound_Detail.cs"},{"SourceFile":"models\\TN_Outbound_Order.cs"},{"SourceFile":"models\\TN_Purchase_Detail.cs"},{"SourceFile":"models\\TN_Purchase_Order.cs"},{"SourceFile":"models\\TN_Putaway_Detail.cs"},{"SourceFile":"models\\TN_Putaway_Order.cs"},{"SourceFile":"models\\TN_Receipt_Detail.cs"},{"SourceFile":"models\\TN_Receipt_Order.cs"},{"SourceFile":"models\\ShippingDetail.cs"},{"SourceFile":"models\\ShippingOrder.cs"},{"SourceFile":"models\\TN_Sorting_Compose.cs"},{"SourceFile":"models\\TN_Sorting_Detail.cs"},{"SourceFile":"models\\SortingOrder.cs"},{"SourceFile":"models\\TN_Sorting_Result.cs"},{"SourceFile":"models\\TN_Supplier.cs"},{"SourceFile":"models\\WCSTask.cs"},{"SourceFile":"models\\TaskAction.cs"},{"SourceFile":"models\\TN_Warehouse.cs"},{"SourceFile":"process\\DeviceProcess.cs"},{"SourceFile":"core\\WCSCore.cs"},{"SourceFile":"api\\WmsController.cs"},{"SourceFile":"api\\ApiHelper.cs"},{"SourceFile":"dispatch\\HostToAGV.cs"},{"SourceFile":"process\\TaskProcess.cs"},{"SourceFile":"util\\LogHelper.cs"},{"SourceFile":"util\\StrHelper.cs"},{"SourceFile":"util\\STAttribute.cs"},{"SourceFile":"wms\\ContainerHelper.cs"},{"SourceFile":"wms\\LocationHelper.cs"},{"SourceFile":"wms\\WMSHelper.cs"},{"SourceFile":"wms\\SYSHelper.cs"},{"SourceFile":"wms\\TEST.cs"},{"SourceFile":"device\\OITcpHelper.cs"},{"SourceFile":"Program.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"util\\Settings.cs"},{"SourceFile":"util\\SqlHelper.cs"},{"SourceFile":"api\\Startup.cs"},{"SourceFile":"dispatch\\NDCHelper.cs"},{"SourceFile":"util\\HttpHelper.cs"},{"SourceFile":"wms\\NormalArea.cs"},{"SourceFile":"wms\\WCSHelper.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs"}],"References":[{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\HH.WCS.Mobox3.Template\\packages\\EasyModbusTCP.5.6.0\\lib\\net40\\EasyModbus.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\Microsoft.Bcl.AsyncInterfaces.7.0.0\\lib\\netstandard2.0\\Microsoft.Bcl.AsyncInterfaces.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\Microsoft.Owin.4.2.2\\lib\\net45\\Microsoft.Owin.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\Microsoft.Owin.Host.HttpListener.4.2.2\\lib\\net45\\Microsoft.Owin.Host.HttpListener.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\Microsoft.Owin.Hosting.4.2.2\\lib\\net45\\Microsoft.Owin.Hosting.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\Microsoft.Win32.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\netfx.force.conflicts.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\netstandard.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\IIS\\Microsoft Web Deploy V3\\Newtonsoft.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\NLog.5.1.1\\lib\\net45\\NLog.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\Owin.1.0\\lib\\net40\\Owin.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\SqlSugar.5.1.3.47\\lib\\SqlSugar.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.AppContext.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Buffers.4.5.1\\lib\\net461\\System.Buffers.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Collections.Concurrent.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Collections.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Collections.NonGeneric.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Collections.Specialized.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.ComponentModel.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.ComponentModel.EventBasedAsync.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.ComponentModel.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.ComponentModel.TypeConverter.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Configuration.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Configuration.Install.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Console.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Data.Common.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.Contracts.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.Debug.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.FileVersionInfo.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.Process.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.StackTrace.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.TextWriterTraceListener.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.Tools.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.TraceSource.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Diagnostics.Tracing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Drawing.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Dynamic.Runtime.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Globalization.Calendars.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Globalization.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Globalization.Extensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.Compression.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.Compression.ZipFile.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.FileSystem.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.FileSystem.DriveInfo.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.FileSystem.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.FileSystem.Watcher.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.IsolatedStorage.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.MemoryMappedFiles.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.Pipes.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.IO.UnmanagedMemoryStream.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Linq.Expressions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Linq.Parallel.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Linq.Queryable.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Memory.4.5.5\\lib\\net461\\System.Memory.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Net.Http.Formatting.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.NameResolution.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.NetworkInformation.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.Ping.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.Requests.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.Security.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.Sockets.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.WebHeaderCollection.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.WebSockets.Client.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Net.WebSockets.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Numerics.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Numerics.Vectors.4.5.0\\lib\\net46\\System.Numerics.Vectors.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.ObjectModel.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Reflection.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Reflection.Extensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Reflection.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Resources.Reader.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Resources.ResourceManager.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Resources.Writer.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Runtime.CompilerServices.Unsafe.6.0.0\\lib\\net461\\System.Runtime.CompilerServices.Unsafe.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.CompilerServices.VisualC.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.Extensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.Handles.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.InteropServices.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.InteropServices.RuntimeInformation.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.Numerics.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.Serialization.Formatters.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.Serialization.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.Serialization.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Runtime.Serialization.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.Claims.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.Cryptography.Algorithms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.Cryptography.Csp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.Cryptography.Encoding.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.Cryptography.Primitives.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.Cryptography.X509Certificates.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.Principal.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Security.SecureString.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.ServiceProcess.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Text.Encoding.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Text.Encoding.Extensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Text.Encodings.Web.7.0.0\\lib\\netstandard2.0\\System.Text.Encodings.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Text.Json.7.0.0\\lib\\netstandard2.0\\System.Text.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Text.RegularExpressions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Threading.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Threading.Overlapped.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Threading.Tasks.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Threading.Tasks.Extensions.4.5.4\\lib\\net461\\System.Threading.Tasks.Extensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Threading.Tasks.Parallel.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Threading.Thread.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Threading.ThreadPool.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Threading.Timer.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.ValueTuple.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Web.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\System.Web.Http.Owin.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Web.Services.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6.1\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Xml.ReaderWriter.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Xml.XDocument.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Xml.XmlDocument.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Xml.XmlSerializer.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Xml.XPath.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Microsoft\\Microsoft.NET.Build.Extensions\\net461\\lib\\System.Xml.XPath.XDocument.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\Topshelf.4.3.0\\lib\\net452\\Topshelf.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\packages\\Topshelf.NLog.4.3.0\\lib\\net452\\Topshelf.NLog.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\HH.WCS.Mobox3.Template\\bin\\Debug\\HH.WCS.Mobox3.Template.exe","OutputItemRelativePath":"HH.WCS.Mobox3.Template.exe"},{"OutputItemFullPath":"D:\\ams\\wcs\\HH.WCS.Mobox3 - 鍓湰\\HH.WCS.Mobox3.Template\\bin\\Debug\\HH.WCS.Mobox3.Template.pdb","OutputItemRelativePath":"HH.WCS.Mobox3.Template.pdb"}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/.vs/HH.WCS.Mobox3.WeiLi/FileContentIndex/57367193-8890-401b-95eb-fa75f34fc9b1.vsidx b/.vs/HH.WCS.Mobox3.WeiLi/FileContentIndex/57367193-8890-401b-95eb-fa75f34fc9b1.vsidx new file mode 100644 index 0000000..9ad48f2 --- /dev/null +++ b/.vs/HH.WCS.Mobox3.WeiLi/FileContentIndex/57367193-8890-401b-95eb-fa75f34fc9b1.vsidx Binary files differ diff --git a/App.config b/App.config new file mode 100644 index 0000000..189fb44 --- /dev/null +++ b/App.config @@ -0,0 +1,74 @@ +锘�?xml version="1.0" encoding="utf-8"?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /> + </startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.3.0.0" newVersion="5.3.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.122.21.1" newVersion="4.122.21.1" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.3" newVersion="8.0.0.3" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Web.Infrastructure" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Formats.Asn1" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git a/App_Start/Startup.cs b/App_Start/Startup.cs new file mode 100644 index 0000000..7259290 --- /dev/null +++ b/App_Start/Startup.cs @@ -0,0 +1,48 @@ +锘縰sing System; +using System.Linq; +using System.Net.Http.Formatting; +using System.Threading.Tasks; +using System.Web.Http; +using Microsoft.Owin; +using Owin; +using Swashbuckle.Application; + +[assembly: OwinStartup(typeof(HH.WCS.Mobox3.DoubleCoin.Startup))] + +namespace HH.WCS.Mobox3.DoubleCoin { + public class Startup { + public void Configuration(IAppBuilder app) { + // 鏈夊叧濡備綍閰嶇疆搴旂敤绋嬪簭鐨勮缁嗕俊鎭紝璇疯闂�https://go.microsoft.com/fwlink/?LinkID=316888 + HttpConfiguration config = new HttpConfiguration(); + config.Routes.MapHttpRoute( + name: "DefaultApi", + routeTemplate: "api/{controller}/{action}/{id}", + defaults: new { id = RouteParameter.Optional } + ); + // Web API routes + //config.MapHttpAttributeRoutes(); + //config.EnableSwagger(c => c.SingleApiVersion("v1", "hh wms api")) + // .EnableSwaggerUi(); + //config.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); + //config.Formatters.Add(new JsonMediaTypeFormatter()); + + + //WebApiConfig.Register(config); + // Web API routes + config.MapHttpAttributeRoutes(); + config.EnableSwagger(c => { + c.SingleApiVersion("v1", "hh wms api"); + c.IncludeXmlComments(System.AppDomain.CurrentDomain.BaseDirectory + "\\HH.WCS.Mobox3.DoubleCoin.xml"); + c.CustomProvider((defaultProvider) => new SwaggerCacheProvider(defaultProvider, $@"{System.AppDomain.CurrentDomain.BaseDirectory}\\HH.WCS.Mobox3.DoubleCoin.xml")); + c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); + } + ).EnableSwaggerUi(c => { + c.InjectJavaScript(System.Reflection.Assembly.GetExecutingAssembly(), "swagger.js"); + }); + config.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); + config.Formatters.Add(new JsonMediaTypeFormatter()); + + app.UseWebApi(config); + } + } +} diff --git a/App_Start/SwaggerConfig.cs b/App_Start/SwaggerConfig.cs new file mode 100644 index 0000000..557097d --- /dev/null +++ b/App_Start/SwaggerConfig.cs @@ -0,0 +1,255 @@ +using System.Web.Http; +using WebActivatorEx; +using HH.WCS.Mobox3.Template; +using Swashbuckle.Application; + +[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")] + +namespace HH.WCS.Mobox3.Template +{ + public class SwaggerConfig + { + public static void Register() + { + var thisAssembly = typeof(SwaggerConfig).Assembly; + + GlobalConfiguration.Configuration + .EnableSwagger(c => + { + // By default, the service root url is inferred from the request used to access the docs. + // However, there may be situations (e.g. proxy and load-balanced environments) where this does not + // resolve correctly. You can workaround this by providing your own code to determine the root URL. + // + //c.RootUrl(req => GetRootUrlFromAppConfig()); + + // If schemes are not explicitly provided in a Swagger 2.0 document, then the scheme used to access + // the docs is taken as the default. If your API supports multiple schemes and you want to be explicit + // about them, you can use the "Schemes" option as shown below. + // + //c.Schemes(new[] { "http", "https" }); + + // Use "SingleApiVersion" to describe a single version API. Swagger 2.0 includes an "Info" object to + // hold additional metadata for an API. Version and title are required but you can also provide + // additional fields by chaining methods off SingleApiVersion. + // + c.SingleApiVersion("v1", "HH.WCS.Mobox3.Template"); + + // If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option. + // + //c.PrettyPrint(); + + // If your API has multiple versions, use "MultipleApiVersions" instead of "SingleApiVersion". + // In this case, you must provide a lambda that tells Swashbuckle which actions should be + // included in the docs for a given API version. Like "SingleApiVersion", each call to "Version" + // returns an "Info" builder so you can provide additional metadata per API version. + // + //c.MultipleApiVersions( + // (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion), + // (vc) => + // { + // vc.Version("v2", "Swashbuckle Dummy API V2"); + // vc.Version("v1", "Swashbuckle Dummy API V1"); + // }); + + // You can use "BasicAuth", "ApiKey" or "OAuth2" options to describe security schemes for the API. + // See https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md for more details. + // NOTE: These only define the schemes and need to be coupled with a corresponding "security" property + // at the document or operation level to indicate which schemes are required for an operation. To do this, + // you'll need to implement a custom IDocumentFilter and/or IOperationFilter to set these properties + // according to your specific authorization implementation + // + //c.BasicAuth("basic") + // .Description("Basic HTTP Authentication"); + // + // NOTE: You must also configure 'EnableApiKeySupport' below in the SwaggerUI section + //c.ApiKey("apiKey") + // .Description("API Key Authentication") + // .Name("apiKey") + // .In("header"); + // + //c.OAuth2("oauth2") + // .Description("OAuth2 Implicit Grant") + // .Flow("implicit") + // .AuthorizationUrl("http://petstore.swagger.wordnik.com/api/oauth/dialog") + // //.TokenUrl("https://tempuri.org/token") + // .Scopes(scopes => + // { + // scopes.Add("read", "Read access to protected resources"); + // scopes.Add("write", "Write access to protected resources"); + // }); + + // Set this flag to omit descriptions for any actions decorated with the Obsolete attribute + //c.IgnoreObsoleteActions(); + + // Each operation be assigned one or more tags which are then used by consumers for various reasons. + // For example, the swagger-ui groups operations according to the first tag of each operation. + // By default, this will be controller name but you can use the "GroupActionsBy" option to + // override with any value. + // + //c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString()); + + // You can also specify a custom sort order for groups (as defined by "GroupActionsBy") to dictate + // the order in which operations are listed. For example, if the default grouping is in place + // (controller name) and you specify a descending alphabetic sort order, then actions from a + // ProductsController will be listed before those from a CustomersController. This is typically + // used to customize the order of groupings in the swagger-ui. + // + //c.OrderActionGroupsBy(new DescendingAlphabeticComparer()); + + // If you annotate Controllers and API Types with + // Xml comments (http://msdn.microsoft.com/en-us/library/b2s063f7(v=vs.110).aspx), you can incorporate + // those comments into the generated docs and UI. You can enable this by providing the path to one or + // more Xml comment files. + // + //c.IncludeXmlComments(GetXmlCommentsPath()); + + // Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types + // exposed in your API. However, there may be occasions when more control of the output is needed. + // This is supported through the "MapType" and "SchemaFilter" options: + // + // Use the "MapType" option to override the Schema generation for a specific type. + // It should be noted that the resulting Schema will be placed "inline" for any applicable Operations. + // While Swagger 2.0 supports inline definitions for "all" Schema types, the swagger-ui tool does not. + // It expects "complex" Schemas to be defined separately and referenced. For this reason, you should only + // use the "MapType" option when the resulting Schema is a primitive or array type. If you need to alter a + // complex Schema, use a Schema filter. + // + //c.MapType<ProductType>(() => new Schema { type = "integer", format = "int32" }); + + // If you want to post-modify "complex" Schemas once they've been generated, across the board or for a + // specific type, you can wire up one or more Schema filters. + // + //c.SchemaFilter<ApplySchemaVendorExtensions>(); + + // In a Swagger 2.0 document, complex types are typically declared globally and referenced by unique + // Schema Id. By default, Swashbuckle does NOT use the full type name in Schema Ids. In most cases, this + // works well because it prevents the "implementation detail" of type namespaces from leaking into your + // Swagger docs and UI. However, if you have multiple types in your API with the same class name, you'll + // need to opt out of this behavior to avoid Schema Id conflicts. + // + //c.UseFullTypeNameInSchemaIds(); + + // Alternatively, you can provide your own custom strategy for inferring SchemaId's for + // describing "complex" types in your API. + // + //c.SchemaId(t => t.FullName.Contains('`') ? t.FullName.Substring(0, t.FullName.IndexOf('`')) : t.FullName); + + // Set this flag to omit schema property descriptions for any type properties decorated with the + // Obsolete attribute + //c.IgnoreObsoleteProperties(); + + // In accordance with the built in JsonSerializer, Swashbuckle will, by default, describe enums as integers. + // You can change the serializer behavior by configuring the StringToEnumConverter globally or for a given + // enum type. Swashbuckle will honor this change out-of-the-box. However, if you use a different + // approach to serialize enums as strings, you can also force Swashbuckle to describe them as strings. + // + //c.DescribeAllEnumsAsStrings(); + + // Similar to Schema filters, Swashbuckle also supports Operation and Document filters: + // + // Post-modify Operation descriptions once they've been generated by wiring up one or more + // Operation filters. + // + //c.OperationFilter<AddDefaultResponse>(); + // + // If you've defined an OAuth2 flow as described above, you could use a custom filter + // to inspect some attribute on each action and infer which (if any) OAuth2 scopes are required + // to execute the operation + // + //c.OperationFilter<AssignOAuth2SecurityRequirements>(); + + // Post-modify the entire Swagger document by wiring up one or more Document filters. + // This gives full control to modify the final SwaggerDocument. You should have a good understanding of + // the Swagger 2.0 spec. - https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md + // before using this option. + // + //c.DocumentFilter<ApplyDocumentVendorExtensions>(); + + // In contrast to WebApi, Swagger 2.0 does not include the query string component when mapping a URL + // to an action. As a result, Swashbuckle will raise an exception if it encounters multiple actions + // with the same path (sans query string) and HTTP method. You can workaround this by providing a + // custom strategy to pick a winner or merge the descriptions for the purposes of the Swagger docs + // + //c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); + + // Wrap the default SwaggerGenerator with additional behavior (e.g. caching) or provide an + // alternative implementation for ISwaggerProvider with the CustomProvider option. + // + //c.CustomProvider((defaultProvider) => new CachingSwaggerProvider(defaultProvider)); + }) + .EnableSwaggerUi(c => + { + // Use the "DocumentTitle" option to change the Document title. + // Very helpful when you have multiple Swagger pages open, to tell them apart. + // + //c.DocumentTitle("My Swagger UI"); + + // Use the "InjectStylesheet" option to enrich the UI with one or more additional CSS stylesheets. + // The file must be included in your project as an "Embedded Resource", and then the resource's + // "Logical Name" is passed to the method as shown below. + // + //c.InjectStylesheet(containingAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testStyles1.css"); + + // Use the "InjectJavaScript" option to invoke one or more custom JavaScripts after the swagger-ui + // has loaded. The file must be included in your project as an "Embedded Resource", and then the resource's + // "Logical Name" is passed to the method as shown above. + // + //c.InjectJavaScript(thisAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testScript1.js"); + + // The swagger-ui renders boolean data types as a dropdown. By default, it provides "true" and "false" + // strings as the possible choices. You can use this option to change these to something else, + // for example 0 and 1. + // + //c.BooleanValues(new[] { "0", "1" }); + + // By default, swagger-ui will validate specs against swagger.io's online validator and display the result + // in a badge at the bottom of the page. Use these options to set a different validator URL or to disable the + // feature entirely. + //c.SetValidatorUrl("http://localhost/validator"); + //c.DisableValidator(); + + // Use this option to control how the Operation listing is displayed. + // It can be set to "None" (default), "List" (shows operations for each resource), + // or "Full" (fully expanded: shows operations and their details). + // + //c.DocExpansion(DocExpansion.List); + + // Specify which HTTP operations will have the 'Try it out!' option. An empty paramter list disables + // it for all operations. + // + //c.SupportedSubmitMethods("GET", "HEAD"); + + // Use the CustomAsset option to provide your own version of assets used in the swagger-ui. + // It's typically used to instruct Swashbuckle to return your version instead of the default + // when a request is made for "index.html". As with all custom content, the file must be included + // in your project as an "Embedded Resource", and then the resource's "Logical Name" is passed to + // the method as shown below. + // + //c.CustomAsset("index", containingAssembly, "YourWebApiProject.SwaggerExtensions.index.html"); + + // If your API has multiple versions and you've applied the MultipleApiVersions setting + // as described above, you can also enable a select box in the swagger-ui, that displays + // a discovery URL for each version. This provides a convenient way for users to browse documentation + // for different API versions. + // + //c.EnableDiscoveryUrlSelector(); + + // If your API supports the OAuth2 Implicit flow, and you've described it correctly, according to + // the Swagger 2.0 specification, you can enable UI support as shown below. + // + //c.EnableOAuth2Support( + // clientId: "test-client-id", + // clientSecret: null, + // realm: "test-realm", + // appName: "Swagger UI" + // //additionalQueryStringParams: new Dictionary<string, string>() { { "foo", "bar" } } + //); + + // If your API supports ApiKey, you can override the default values. + // "apiKeyIn" can either be "query" or "header" + // + //c.EnableApiKeySupport("apiKey", "header"); + }); + } + } +} diff --git a/App_Start/SwaggerControllerDescProvider.cs b/App_Start/SwaggerControllerDescProvider.cs new file mode 100644 index 0000000..8269e93 --- /dev/null +++ b/App_Start/SwaggerControllerDescProvider.cs @@ -0,0 +1,82 @@ +锘縰sing Swashbuckle.Swagger; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Xml; + +namespace HH.WCS.Mobox3.DoubleCoin { + /// <summary> + /// swagger 鏄剧ず鎺у埗鍣ㄧ殑鎻忚堪 + /// </summary> + public class SwaggerCacheProvider : ISwaggerProvider + { + private readonly ISwaggerProvider _swaggerProvider; + private static ConcurrentDictionary<string, SwaggerDocument> _cache = new ConcurrentDictionary<string, SwaggerDocument>(); + private readonly string _xmlPath; + + /// <summary> + /// + /// </summary> + /// <param name="swaggerProvider"></param> + /// <param name="xmlpath">xml鏂囨。璺緞</param> + public SwaggerCacheProvider(ISwaggerProvider swaggerProvider, string xmlpath) + { + _swaggerProvider = swaggerProvider; + _xmlPath = xmlpath; + } + + public SwaggerDocument GetSwagger(string rootUrl, string apiVersion) + { + var cacheKey = string.Format("{0}_{1}", rootUrl, apiVersion); + //鍙鍙栦竴娆�+ if (!_cache.TryGetValue(cacheKey, out SwaggerDocument srcDoc)) + { + srcDoc = _swaggerProvider.GetSwagger(rootUrl, apiVersion); + + srcDoc.vendorExtensions = new Dictionary<string, object> + { + { "ControllerDesc", GetControllerDesc() } + }; + _cache.TryAdd(cacheKey, srcDoc); + } + return srcDoc; + } + + /// <summary> + /// 浠嶢PI鏂囨。涓鍙栨帶鍒跺櫒鎻忚堪 + /// </summary> + /// <returns>鎵�湁鎺у埗鍣ㄦ弿杩�/returns> + public ConcurrentDictionary<string, string> GetControllerDesc() + { + ConcurrentDictionary<string, string> controllerDescDict = new ConcurrentDictionary<string, string>(); + if (File.Exists(_xmlPath)) + { + XmlDocument xmldoc = new XmlDocument(); + xmldoc.Load(_xmlPath); + + string[] arrPath; + int cCount = "Controller".Length; + foreach (XmlNode node in xmldoc.SelectNodes("//member")) + { + string type = node.Attributes["name"].Value; + if (type.StartsWith("T:")) + { + arrPath = type.Split('.'); + string controllerName = arrPath[arrPath.Length - 1]; + if (controllerName.EndsWith("Controller")) //鎺у埗鍣�+ { + //鑾峰彇鎺у埗鍣ㄦ敞閲�+ XmlNode summaryNode = node.SelectSingleNode("summary"); + string key = controllerName.Remove(controllerName.Length - cCount, cCount); + if (summaryNode != null && !string.IsNullOrEmpty(summaryNode.InnerText) && !controllerDescDict.ContainsKey(key)) + { + controllerDescDict.TryAdd(key, summaryNode.InnerText.Trim()); + } + } + } + } + } + return controllerDescDict; + } + } +} diff --git a/HH.WCS.Mobox3.DoubleCoin.csproj b/HH.WCS.Mobox3.DoubleCoin.csproj new file mode 100644 index 0000000..01560e4 --- /dev/null +++ b/HH.WCS.Mobox3.DoubleCoin.csproj @@ -0,0 +1,305 @@ +锘�?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>HH.WCS.Mobox3.DoubleCoin</RootNamespace> + <AssemblyName>HH.WCS.Mobox3.DoubleCoin</AssemblyName> + <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <Deterministic>true</Deterministic> + <TargetFrameworkProfile /> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>x86</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <DocumentationFile>bin\Debug\HH.WCS.Mobox3.DoubleCoin.xml</DocumentationFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <NoWarn>$(NoWarn);CS1591</NoWarn> + </PropertyGroup> + <PropertyGroup> + <StartupObject>HH.WCS.Mobox3.DoubleCoin.Program</StartupObject> + </PropertyGroup> + <ItemGroup> + <Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL"> + <HintPath>packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath> + </Reference> + <Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL"> + <HintPath>packages\BouncyCastle.Cryptography.2.4.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath> + </Reference> + <Reference Include="EasyModbus, Version=5.6.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>packages\EasyModbusTCP.5.6.0\lib\net40\EasyModbus.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Bcl.HashCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.Bcl.HashCode.1.1.1\lib\net461\Microsoft.Bcl.HashCode.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=3.1.32.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.Extensions.Logging.Abstractions.3.1.32\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Owin, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Owin.Host.HttpListener, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Owin.Host.HttpListener.4.2.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Owin.Hosting, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\packages\Microsoft.Owin.Hosting.4.2.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Web.Infrastructure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.Web.Infrastructure.2.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json.Bson, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll</HintPath> + </Reference> + <Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> + <HintPath>packages\NLog.5.3.4\lib\net46\NLog.dll</HintPath> + </Reference> + <Reference Include="Opc.Ua.Client, Version=1.5.374.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8, processorArchitecture=MSIL"> + <HintPath>packages\OPCFoundation.NetStandard.Opc.Ua.Client.1.5.374.126\lib\netstandard2.0\Opc.Ua.Client.dll</HintPath> + </Reference> + <Reference Include="Opc.Ua.Configuration, Version=1.5.374.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8, processorArchitecture=MSIL"> + <HintPath>packages\OPCFoundation.NetStandard.Opc.Ua.Configuration.1.5.374.126\lib\netstandard2.0\Opc.Ua.Configuration.dll</HintPath> + </Reference> + <Reference Include="Opc.Ua.Core, Version=1.5.374.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8, processorArchitecture=MSIL"> + <HintPath>packages\OPCFoundation.NetStandard.Opc.Ua.Core.1.5.374.126\lib\netstandard2.0\Opc.Ua.Core.dll</HintPath> + </Reference> + <Reference Include="Opc.Ua.Gds.Client.Common, Version=1.5.374.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8, processorArchitecture=MSIL"> + <HintPath>packages\OPCFoundation.NetStandard.Opc.Ua.Gds.Client.Common.1.5.374.126\lib\netstandard2.0\Opc.Ua.Gds.Client.Common.dll</HintPath> + </Reference> + <Reference Include="Opc.Ua.Gds.Server.Common, Version=1.5.374.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8, processorArchitecture=MSIL"> + <HintPath>packages\OPCFoundation.NetStandard.Opc.Ua.Gds.Server.Common.1.5.374.126\lib\netstandard2.0\Opc.Ua.Gds.Server.Common.dll</HintPath> + </Reference> + <Reference Include="Opc.Ua.Security.Certificates, Version=1.5.374.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8, processorArchitecture=MSIL"> + <HintPath>packages\OPCFoundation.NetStandard.Opc.Ua.Security.Certificates.1.5.374.126\lib\netstandard2.0\Opc.Ua.Security.Certificates.dll</HintPath> + </Reference> + <Reference Include="Opc.Ua.Server, Version=1.5.374.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8, processorArchitecture=MSIL"> + <HintPath>packages\OPCFoundation.NetStandard.Opc.Ua.Server.1.5.374.126\lib\netstandard2.0\Opc.Ua.Server.dll</HintPath> + </Reference> + <Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL"> + <HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath> + </Reference> + <Reference Include="S7.Net, Version=0.20.0.0, Culture=neutral, PublicKeyToken=d5812d469e84c693, processorArchitecture=MSIL"> + <HintPath>..\packages\S7netplus.0.20.0\lib\net452\S7.Net.dll</HintPath> + </Reference> + <Reference Include="SqlSugar, Version=5.1.4.168, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>packages\SqlSugar.5.1.4.169\lib\SqlSugar.dll</HintPath> + </Reference> + <Reference Include="Swashbuckle.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cd1bb07a5ac7c7bc, processorArchitecture=MSIL"> + <HintPath>..\packages\Swashbuckle.Core.5.6.0\lib\net40\Swashbuckle.Core.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath> + </Reference> + <Reference Include="System.ComponentModel.Composition" /> + <Reference Include="System.Configuration" /> + <Reference Include="System.Configuration.Install" /> + <Reference Include="System.Core" /> + <Reference Include="System.Diagnostics.DiagnosticSource, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Diagnostics.DiagnosticSource.6.0.1\lib\net461\System.Diagnostics.DiagnosticSource.dll</HintPath> + </Reference> + <Reference Include="System.Formats.Asn1, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Formats.Asn1.8.0.1\lib\net462\System.Formats.Asn1.dll</HintPath> + </Reference> + <Reference Include="System.IdentityModel" /> + <Reference Include="System.IO.Compression" /> + <Reference Include="System.Management" /> + <Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath> + </Reference> + <Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath> + </Reference> + <Reference Include="System.Net.Http.Formatting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.AspNet.WebApi.Client.6.0.0\lib\net45\System.Net.Http.Formatting.dll</HintPath> + </Reference> + <Reference Include="System.Numerics" /> + <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> + </Reference> + <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath> + </Reference> + <Reference Include="System.Runtime.Serialization" /> + <Reference Include="System.Security.Cryptography.Algorithms, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net461\System.Security.Cryptography.Algorithms.dll</HintPath> + </Reference> + <Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath> + </Reference> + <Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath> + </Reference> + <Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath> + </Reference> + <Reference Include="System.ServiceModel" /> + <Reference Include="System.ServiceModel.Primitives, Version=4.10.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>packages\System.ServiceModel.Primitives.4.10.0\lib\net461\System.ServiceModel.Primitives.dll</HintPath> + </Reference> + <Reference Include="System.ServiceProcess" /> + <Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath> + </Reference> + <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath> + </Reference> + <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath> + </Reference> + <Reference Include="System.Web" /> + <Reference Include="System.Web.Http, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.AspNet.WebApi.Core.5.3.0\lib\net45\System.Web.Http.dll</HintPath> + </Reference> + <Reference Include="System.Web.Http.Owin, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.AspNet.WebApi.Owin.5.3.0\lib\net45\System.Web.Http.Owin.dll</HintPath> + </Reference> + <Reference Include="System.Web.Http.WebHost, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.AspNet.WebApi.WebHost.5.3.0\lib\net45\System.Web.Http.WebHost.dll</HintPath> + </Reference> + <Reference Include="System.Web.Services" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + <Reference Include="Topshelf, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL"> + <HintPath>..\packages\Topshelf.4.3.0\lib\net452\Topshelf.dll</HintPath> + </Reference> + <Reference Include="Topshelf.NLog, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL"> + <HintPath>..\packages\Topshelf.NLog.4.3.0\lib\net452\Topshelf.NLog.dll</HintPath> + </Reference> + <Reference Include="WebActivatorEx, Version=2.0.0.0, Culture=neutral, PublicKeyToken=7b26dc2a43f6a0d4, processorArchitecture=MSIL"> + <HintPath>packages\WebActivatorEx.2.2.0\lib\net40\WebActivatorEx.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="api\DebugController.cs" /> + <Compile Include="api\MoboxController.cs" /> + <Compile Include="api\AgvController.cs" /> + <Compile Include="api\ApiModel.cs" /> + <Compile Include="App_Start\SwaggerControllerDescProvider.cs" /> + <Compile Include="core\WMSCore.cs" /> + <Compile Include="device\ModbusHelper.cs" /> + <Compile Include="device\OpcUaHelper.cs" /> + <Compile Include="device\PlcHelper.cs" /> + <Compile Include="device\S7Helper.cs" /> + <Compile Include="device\ScanCodeHelper.cs" /> + <Compile Include="device\TcpClient.cs" /> + <Compile Include="device\TcpServer.cs" /> + <Compile Include="dispatch\GZRobot.cs" /> + <Compile Include="dispatch\HanAo.cs" /> + <Compile Include="dispatch\NDC.cs" /> + <Compile Include="core\Monitor.cs" /> + <Compile Include="dispatch\NDCApi.cs" /> + <Compile Include="models\BaseModel.cs" /> + <Compile Include="models\TN_CG_Detail.cs" /> + <Compile Include="models\TN_CAR_IN.cs" /> + <Compile Include="models\TN_Component_Detail.cs" /> + <Compile Include="models\TN_Container.cs" /> + <Compile Include="models\TN_DayProDetail.cs" /> + <Compile Include="models\TN_EquipProDetail.cs" /> + <Compile Include="models\TN_InventoryM.cs" /> + <Compile Include="models\TN_Location.cs" /> + <Compile Include="models\TN_Loc_Container.cs" /> + <Compile Include="models\TN_MonthProDetail.cs" /> + <Compile Include="models\TN_Operator_Info.cs" /> + <Compile Include="models\TN_RemeltDetail.cs" /> + <Compile Include="models\TN_SurplusDetail.cs" /> + <Compile Include="models\TN_TN_SPE.cs" /> + <Compile Include="models\TN_WeekProDetail.cs" /> + <Compile Include="models\TN_WorkOrder.cs" /> + <Compile Include="models\TN_Task.cs" /> + <Compile Include="models\TN_Task_Action.cs" /> + <Compile Include="models\TN_YearProDetail.cs" /> + <Compile Include="process\DeviceProcess.cs" /> + <Compile Include="core\WCSCore.cs" /> + <Compile Include="api\WmsController.cs" /> + <Compile Include="api\ApiHelper.cs" /> + <Compile Include="dispatch\HostToAGV.cs" /> + <Compile Include="process\TaskProcess.cs" /> + <Compile Include="util\LogHelper.cs" /> + <Compile Include="wms\ContainerHelper.cs" /> + <Compile Include="wms\LocationHelper.cs" /> + <Compile Include="wms\SpecHelper.cs" /> + <Compile Include="wms\WMSHelper.cs" /> + <Compile Include="wms\SYSHelper.cs" /> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="util\Settings.cs" /> + <Compile Include="util\SqlHelper.cs" /> + <Compile Include="App_Start\Startup.cs" /> + <Compile Include="dispatch\NDCHelper.cs" /> + <Compile Include="util\HttpHelper.cs" /> + <Compile Include="wms\WCSHelper.cs" /> + </ItemGroup> + <ItemGroup> + <None Include=".editorconfig" /> + <None Include="App.config" /> + <None Include="config\config.json"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <Content Include="config\configDesc.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="readme.txt" /> + <EmbeddedResource Include="swagger.js"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include=".NETFramework,Version=v4.6.2"> + <Visible>False</Visible> + <ProductName>Microsoft .NET Framework 4.6.2 %28x86 鍜�x64%29</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>false</Install> + </BootstrapperPackage> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project> \ No newline at end of file diff --git a/HH.WCS.Mobox3.DoubleCoin.sln b/HH.WCS.Mobox3.DoubleCoin.sln new file mode 100644 index 0000000..dafaf94 --- /dev/null +++ b/HH.WCS.Mobox3.DoubleCoin.sln @@ -0,0 +1,30 @@ +锘�+Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.35026.282 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HH.WCS.Mobox3.DoubleCoin", "HH.WCS.Mobox3.DoubleCoin.csproj", "{EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2B600D60-6469-4E6C-9692-C01E7A42018E}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EBE15A59-A43A-43BE-8B4B-A6EC42E11DF6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8F82F32F-C59B-4BE6-A074-82CC2830FE2E} + EndGlobalSection +EndGlobal diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..d006239 --- /dev/null +++ b/Program.cs @@ -0,0 +1,172 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.core; +using HH.WCS.Mobox3.DoubleCoin.device; +using HH.WCS.Mobox3.DoubleCoin.util; +using Microsoft.Owin.Hosting; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Topshelf; +using Monitor = HH.WCS.Mobox3.DoubleCoin.core.Monitor; + +namespace HH.WCS.Mobox3.DoubleCoin +{ + internal class Program + { + static void Main(string[] args) + { + //鍩虹璁剧疆淇℃伅鍒濆鍖�+ Settings.Init(); + //1.0 寮�惎api + Startup(); + //2.0 寮�惎tcp + StartTcp(); + //3.0 寮�惎S7 + StartS7(); + //4.0 寮�惎Modbus + //StartModbus(); + + //5.0 寮�惎绾跨▼ + var rc = HostFactory.Run(x => + { + x.Service<WorkThread>(s => + { + s.ConstructUsing(name => new WorkThread()); + s.WhenStarted(tc => tc.Start()); + s.WhenStopped(tc => tc.Stop()); + }); + x.RunAsLocalSystem(); + + x.SetDescription("hh123"); + x.SetDisplayName("hh123.wms"); + x.SetServiceName("hh123.wms"); + }); + + var exitCode = (int)Convert.ChangeType(rc, rc.GetTypeCode()); + Environment.ExitCode = exitCode; + } + + /// <summary> + /// 寮�惎API鍗忚閫氳 + /// </summary> + private static void Startup() + { + Console.WriteLine("Startup ApiController"); + Task.Run(() => + { + var url = Settings.WebApiUrl; + Console.WriteLine(url); + using (WebApp.Start<Startup>(url)) + { + Console.WriteLine("API,Running on {0}", url); + Console.ReadLine(); + } + }); + } + + /// <summary> + /// 寮�惎TCP鍗忚閫氳锛屾湇鍔$ + /// </summary> + private static void StartTcp() + { + var tcpServerIP = Settings.TCPServerIP; + var tcpServerPort = Settings.TCPServerPort; + new TcpServer(tcpServerIP, tcpServerPort); + + } + + /// <summary> + /// 寮�惎S7鍗忚閫氳 + /// </summary> + private static void StartS7() + { + //鎵�湁鐨凷7璁惧 + var allPLCDevice = Settings.ProductionLines; + + if (allPLCDevice.Count > 0) + { + foreach (var item in allPLCDevice) + { + new S7Helper(item.ProductionLine_IP, (short)item.ProductionLine_Rack, (short)item.ProductionLine_Slot); + Console.WriteLine("S7ProductionLineHelper," + item.ProductionLine_IP); + } + } + + //绉伴噸鐨凷7璁惧 + var weightPLCDevice = Settings.WeightDevices; + + if (weightPLCDevice.Count > 0) + { + foreach (var item in weightPLCDevice) + { + new S7Helper(item.WeightDevice_IP, (short)item.WeightDevice_Rack, (short)item.WeightDevice_Slot); + Console.WriteLine("S7WeightDeviceHelper," + item.WeightDevice_Name); + } + } + } + + /// <summary> + /// 寮�惎Modbus鍗忚閫氳 + /// </summary> + private static void StartModbus() + { + //鎵�湁鐨凪odbus璁惧 + //var allPLCDevice = Settings.SafeDoorDevices; + + //if (allPLCDevice.Count > 0) + //{ + // foreach (var item in allPLCDevice) + // { + // new ModbusHelper(item.IPAddress, item.Port); + // Console.WriteLine("ModbusHelper," + item.IPAddress); + // } + //} + } + + public class WorkThread + { + public void Start() + { + List<Task> tasks = new List<Task>(); + //娣诲姞浠诲姟鎺ㄩ�绾跨▼ + tasks.Add(GetTask(WCSCore.Dispatch)); + + //娣诲姞鑷畾涔夌嚎绋�+ tasks.Add(GetTask(Monitor.CheckEmptyCnt));//妫�祴绌烘墭鐩�+ + tasks.Add(GetTask(Monitor.CheckCntAndBoard));//鍚屾 TN_Container 鍧囪瀹炴椂鏄剧ず + + tasks.Add(GetTask(Monitor.CheckNoOkCg));//妫�祴婊℃墭缂撳瓨搴撳尯涓嶅悎鏍肩殑鐗╁搧锛屾弧鎵樺嚭搴撳妫�+ + //鏍规嵁S7/Modbus鍗忚鍒ゆ柇杈撻�绾跨殑淇″彿 鍘熸潗鏂欎骇绾垮簱鍖�>婊℃墭缂撳瓨搴撳尯锛岀┖鎵樼紦瀛樺簱鍖�>鍘熸潗鏂欎骇绾垮簱鍖�+ tasks.Add(GetTask(Monitor.CheckS7Devices)); + + tasks.Add(GetTask(Monitor.SynchronizationEquipPro));//鍚屾 TN_EquipProDetail TN_InventoryM + + tasks.Add(GetTask(Monitor.FullOutTime));//婊℃墭杩囨湡鍑哄簱 婊℃墭杩囨湡鍥炲簱锛屾弧鎵樿繃鏈熷洖鐐�+ + Task.WaitAll(tasks.ToArray()); + } + public void Stop() { Console.WriteLine("work stopped"); } + private Task GetTask(Action action) + { + var task = Task.Run(() => + { + while (true) + { + try + { + action(); + } + catch (Exception ex) + { + LogHelper.Error(ex.Message, ex); + } + Thread.Sleep(3000); + } + }); + return task; + } + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e76b5ba --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 鏈夊叧绋嬪簭闆嗙殑涓�埇淇℃伅鐢变互涓�+// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�鍙慨鏀�+// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭� +[assembly: AssemblyTitle("HH.WCS.Mobox3.DoubleCoin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HH.WCS.Mobox3.DoubleCoin")] +[assembly: AssemblyCopyright("Copyright 漏 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 灏�ComVisible 璁剧疆涓�false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷 +//瀵�COM 缁勪欢涓嶅彲瑙併�濡傛灉闇�浠�COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷 +//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�璁剧疆涓�true銆�+[assembly: ComVisible(false)] + +// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID +[assembly: Guid("8e589c0d-7d65-474d-8ced-e34e087126a1")] + +// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�缁勬垚: +// +// 涓荤増鏈�+// 娆$増鏈�+// 鐢熸垚鍙�+// 淇鍙�+// +//鍙互鎸囧畾鎵�湁杩欎簺鍊硷紝涔熷彲浠ヤ娇鐢ㄢ�鐢熸垚鍙封�鍜屸�淇鍙封�鐨勯粯璁ゅ� +//閫氳繃浣跨敤 "*"锛屽涓嬫墍绀� +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/api/AgvController.cs b/api/AgvController.cs new file mode 100644 index 0000000..6622100 --- /dev/null +++ b/api/AgvController.cs @@ -0,0 +1,35 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.core; +using HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.process; +using HH.WCS.Mobox3.DoubleCoin.wms; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Reflection; +using System.Web.Http; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; +using static HH.WCS.Mobox3.DoubleCoin.dispatch.NDC; +using System.Linq; +using HH.WCS.Mobox3.DoubleCoin.util; + +namespace HH.WCS.Mobox3.DoubleCoin.api +{ + /// <summary> + /// 璁惧淇℃伅涓婃姤锛坔osttoagv涓婃姤銆佹澀濂ュ爢鍨涙満銆佸浗鑷猘gv锛�+ /// </summary> + [RoutePrefix("agv")] + public class AgvController : System.Web.Http.ApiController + { + /// <summary> + /// NDC HostToAGV浠诲姟鐘舵�鍥炴姤 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("AGVCallbackState")] + public ReturnResult AGVCallbackState(AgvTaskState model) + { + LogHelper.Info("NDC HostToAGV浠诲姟鐘舵�鍥炴姤锛� + JsonConvert.SerializeObject(model), "HosttoagvTask"); + return WCSCore.OperateAgvTaskStatus(model); + } + } +} diff --git a/api/ApiHelper.cs b/api/ApiHelper.cs new file mode 100644 index 0000000..41acf7d --- /dev/null +++ b/api/ApiHelper.cs @@ -0,0 +1,1662 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.device; +using HH.WCS.Mobox3.DoubleCoin.models; +using HH.WCS.Mobox3.DoubleCoin.process; +using HH.WCS.Mobox3.DoubleCoin.util; +using HH.WCS.Mobox3.DoubleCoin.wms; +using Newtonsoft.Json; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Runtime.ConstrainedExecution; +using System.Threading; +using System.Threading.Tasks; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; +using static HH.WCS.Mobox3.DoubleCoin.api.OtherModel; + +namespace HH.WCS.Mobox3.DoubleCoin.api +{ + /// <summary> + /// api鎺ュ彛杈呭姪绫�+ /// </summary> + public class ApiHelper + { + static ApiHelper() + { + + } + + /// <summary> + /// PDA婊℃墭鍑哄簱鎶芥 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult PDAFullCheckOut(PDAFullCheckInfo model) + { + LogHelper.Info("瑙﹀彂API锛歅DA婊℃墭鍑哄簱鎶芥" + JsonConvert.SerializeObject(model), "API"); + var db = new SqlHelper<object>().GetInstance(); + var result = new SimpleResult();//杩斿洖缁撴灉 + try + { + var locCnt = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.rfId); + if (locCnt == null) + { + result.resultCode = 1; + result.resultMsg = $"瀹瑰櫒{ model.rfId}娌℃湁缁戝畾杩囪揣浣�; + LogHelper.Info(result.resultMsg); + return result; + } + var cG_Detail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCnt.S_CNTR_CODE); + if (cG_Detail == null) + { + result.resultCode = 2; + result.resultMsg = $"瀹瑰櫒{locCnt.S_CNTR_CODE}娌℃湁璐у搧"; + LogHelper.Info(result.resultMsg); + return result; + } + + + var startLoc = db.Queryable<TN_Location>().First(a => a.S_AREA_CODE == Settings.Areas[1] && a.S_CODE == locCnt.S_LOC_CODE && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y"); + if (startLoc == null) + { + result.resultCode = 3; + result.resultMsg = $"璧风偣璐т綅{locCnt.S_LOC_CODE}鏈В閿侊紝鎴栬�涓嶅睘浜庢娊妫�尯"; + LogHelper.Info(result.resultMsg); + return result; + } + + var endLoc = db.Queryable<TN_Location>(). + Where(o => o.S_AREA_CODE == Settings.Areas[7] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.C_ENABLE == "Y" && o.N_CURRENT_NUM == 0). + OrderBy(o => o.T_MODIFY, OrderByType.Asc).First();//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣�+ + if (endLoc == null) + { + result.resultCode = 4; + result.resultMsg = $"瀹瑰櫒{locCnt.S_CNTR_CODE}鏈壘鍒板悎閫傜殑缁堢偣璐т綅"; + LogHelper.Info(result.resultMsg); + return result; + } + + //鍒涘缓浜哄伐鎷嗙洏鍑哄簱浠诲姟 + if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "浜哄伐鍑哄簱鎶芥", 3, locCnt.S_CNTR_CODE, cG_Detail.S_SPE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ LogHelper.Info($"鐢熸垚浜哄伐鍑哄簱鎶芥浠诲姟鎴愬姛锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"); + cG_Detail.S_ITEM_STATE = "寰呮"; + cG_Detail.N_ITEM_STATE = 1; + db.Updateable<TN_CG_Detail>().UpdateColumns(it => new { it.S_ITEM_STATE, it.N_ITEM_STATE }).ExecuteCommand(); + + Task task99 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "浜哄伐鍑哄簱鎶芥", locCnt.S_CNTR_CODE); + }); + + result.resultCode = 0; + result.resultMsg = $"鎴愬姛"; + return result; + } + else + { + result.resultCode = 5; + result.resultMsg = $"鐢熸垚浜哄伐鍑哄簱鎶芥浠诲姟澶辫触锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + + } + catch (Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + /// <summary> + /// PDA婊℃墭鎶芥鍒ゆ柇 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult PDAFullCheckIn(PDAFullCheckInfo model) + { + LogHelper.Info("瑙﹀彂API锛歅DA婊℃墭鎶芥鍒ゆ柇" + JsonConvert.SerializeObject(model), "API"); + var db = new SqlHelper<object>().GetInstance(); + var result = new SimpleResult();//杩斿洖缁撴灉 + try + { + var locCnt = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.rfId); + if (locCnt == null) + { + result.resultCode = 1; + result.resultMsg = $"瀹瑰櫒{ model.rfId}娌℃湁缁戝畾杩囪揣浣�; + LogHelper.Info(result.resultMsg); + return result; + } + + var cG_Detail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCnt.S_CNTR_CODE); + if (cG_Detail == null) + { + result.resultCode = 2; + result.resultMsg = $"瀹瑰櫒{locCnt.S_CNTR_CODE}娌℃湁璐у搧"; + LogHelper.Info(result.resultMsg); + return result; + } + + + var startLoc = db.Queryable<TN_Location>().First(a => a.S_AREA_CODE == Settings.Areas[7] && a.S_CODE == locCnt.S_LOC_CODE && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y"); + if (startLoc == null) + { + result.resultCode = 3; + result.resultMsg = $"璧风偣璐т綅{locCnt.S_LOC_CODE}鏈В閿侊紝鎴栬�涓嶅睘浜庢娊妫�尯"; + LogHelper.Info(result.resultMsg); + return result; + } + + var endLoc = new TN_Location(); + if (model.cgState == 0)//鍚堟牸鍥炲簱 + { + cG_Detail.N_ITEM_STATE = 0; + cG_Detail.S_ITEM_STATE = "鍚堟牸"; + endLoc = db.Queryable<TN_Location>(). + Where(o => o.S_AREA_CODE == Settings.Areas[1] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.C_ENABLE == "Y" && o.N_CURRENT_NUM == 0). + OrderBy(o => o.T_MODIFY, OrderByType.Asc).First();//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣�+ } + else if (model.cgState == 2)//涓嶅悎鏍煎洖鐐�+ { + cG_Detail.N_ITEM_STATE = 2; + cG_Detail.S_ITEM_STATE = "涓嶅悎鏍�; + endLoc = db.Queryable<TN_Location>(). + Where(o => o.S_AREA_CODE == Settings.Areas[8] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.C_ENABLE == "Y" && o.N_CURRENT_NUM == 0). + OrderBy(o => o.T_MODIFY, OrderByType.Asc).First();//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣�+ } + else + { + result.resultCode = 6; + result.resultMsg = $"鐗╂枡鐘舵�鍙兘涓�鎴�锛屽嵆鍙傛暟cgState = 2 鎴�= 0锛屽鏋滀负鍏朵粬鍊硷紝鍒欎笉澶勭悊锛�鍚堟牸锛�涓嶅悎鏍�; + LogHelper.Info(result.resultMsg); + return result; + } + + + if (endLoc == null) + { + result.resultCode = 4; + result.resultMsg = $"瀹瑰櫒{locCnt.S_CNTR_CODE}鏈壘鍒板悎閫傜殑缁堢偣璐т綅"; + LogHelper.Info(result.resultMsg); + return result; + } + var typeName = (model.cgState == 0) ? "浜哄伐鎶芥鍥炲簱" : "浜哄伐鎶芥鍥炵倝"; + //鍒涘缓浜哄伐鎷嗙洏鍑哄簱浠诲姟 + if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, typeName, 3, locCnt.S_CNTR_CODE,out string taskNo,cG_Detail.S_SPE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ LogHelper.Info($"鐢熸垚{typeName}浠诲姟鎴愬姛锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"); + + db.Updateable<TN_CG_Detail>().UpdateColumns(it => new { it.S_ITEM_STATE, it.N_ITEM_STATE }).ExecuteCommand(); + + Task task99 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, typeName, locCnt.S_CNTR_CODE); + }); + + Task task2 = Task.Run(() => + { + if (model.cgState == 2) + { + var target = new TN_RemeltDetail() + { + CntCode = locCnt.S_CNTR_CODE, + StartLoc = startLoc.S_CODE, + LoginName = model.staff, + ItemCode = cG_Detail.S_ITEM_CODE, + Spec = cG_Detail.S_SPE, + CarCode = cG_Detail.S_CAR_CODE, + Weight = cG_Detail.F_QTY, + RemeltTime = DateTime.Now, + TaskNo = taskNo + }; + SpecHelper.InsertRemeltDetail(target); + } + }); + + result.resultCode = 0; + result.resultMsg = $"鎴愬姛"; + return result; + } + else + { + result.resultCode = 5; + result.resultMsg = $"鐢熸垚{typeName}浠诲姟澶辫触锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + + } + catch (Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + /// <summary> + /// 浜哄伐娆″搧鍥炵倝 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult PDAReturnReset(PDAReturnResetInfo model) + { + LogHelper.Info("瑙﹀彂API锛氫汉宸ユ鍝佸洖鐐� + JsonConvert.SerializeObject(model), "API"); + var db = new SqlHelper<object>().GetInstance(); + var result = new SimpleResult();//杩斿洖缁撴灉 + + try + { + var startLoc = db.Queryable<TN_Location>().First(o => o.S_CODE == model.startLoc && o.N_CURRENT_NUM ==0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE=="鏃� && o.S_AREA_CODE == Settings.Areas[4]); + if (startLoc == null) + { + result.resultCode = 1; + result.resultMsg = $"鏈壘鍒板悎閫傜殑璧风偣淇℃伅锛岃姹傦細o.S_CODE == { model.startLoc} && o.N_CURRENT_NUM ==0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == 鏃�&& o.S_AREA_CODE == {Settings.Areas[4]}"; + LogHelper.Info(result.resultMsg); + return result; + } + + var endLoc = db.Queryable<TN_Location>().First(o =>o.S_AREA_CODE == Settings.Areas[11] && o.N_CURRENT_NUM == 0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃�); + if (endLoc == null) + { + result.resultCode = 2; + result.resultMsg = $"鏈壘鍒板悎閫傜殑缁堢偣淇℃伅锛岃姹傦細o.S_AREA_CODE == {Settings.Areas[11]} && o.N_CURRENT_NUM == 0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == 鏃�; + LogHelper.Info(result.resultMsg); + return result; + } + + var cgInfo = db.Queryable<TN_CG_Detail>().First(a=>a.S_CNTR_CODE == model.rfId); + if (cgInfo == null) + { + result.resultCode = 3; + result.resultMsg = $"鏈壘鍒板搴旂殑鐗╂枡淇℃伅锛岃姹傦細a.S_CNTR_CODE == {model.rfId}"; + LogHelper.Info(result.resultMsg); + return result; + } + + var task1 = new TN_Task() + { + S_CODE = WCSHelper.GenerateTaskNo(), + S_START_AREA = startLoc.S_AREA_CODE, + S_END_AREA = endLoc.S_AREA_CODE, + S_START_LOC = startLoc.S_CODE, + S_END_LOC = endLoc.S_CODE, + S_TYPE = "浜哄伐娆″搧鍥炵倝", + N_B_STATE = 0, + S_B_STATE = "绛夊緟", + S_CNTR_CODE = model.rfId, + S_SPEC = cgInfo.S_ITEM_SPEC, + }; + + startLoc.N_LOCK_STATE = 2; + startLoc.S_LOCK_STATE = "鍑哄簱閿�; + startLoc.N_CURRENT_NUM = 1; + startLoc.T_MODIFY = System.DateTime.Now; + + endLoc.N_LOCK_STATE = 1; + endLoc.S_LOCK_STATE = "鍏ュ簱閿�; + startLoc.T_MODIFY = System.DateTime.Now; + + using (var tran = db.Ado.UseTran()) + { + var locCnt = db.Queryable<TN_Loc_Container>().First(o => o.S_CNTR_CODE == model.rfId && o.S_LOC_CODE != model.startLoc); + TN_Location locOld = null; + if (locCnt != null) + { + locOld = db.Queryable<TN_Location>().First(o => o.S_CODE == locCnt.S_LOC_CODE); + if (locOld != null) + { + locOld.N_CURRENT_NUM = 0; + if (db.Updateable<TN_Location>(locOld).UpdateColumns(it => new { it.N_CURRENT_NUM }).ExecuteCommand() <= 0) + { + tran.RollbackTran(); + result.resultCode = 4; + result.resultMsg = $"鏇存柊鏃ц揣浣嶅け璐ワ紝{locOld.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + locCnt.S_LOC_CODE = model.startLoc; + if (db.Updateable<TN_Loc_Container>(locCnt).UpdateColumns(it => new { it.S_LOC_CODE }).ExecuteCommand() <= 0) + { + tran.RollbackTran(); + result.resultCode = 5; + result.resultMsg = $"鏇存柊璐т綅瀹瑰櫒鍏崇郴琛紙鎹㈢粦锛夊け璐ワ紝{model.startLoc}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + else + { + locCnt = new TN_Loc_Container() + { + S_LOC_CODE = model.startLoc, + S_CNTR_CODE = model.rfId, + }; + if (db.Insertable<TN_Loc_Container>(locCnt).ExecuteCommand() <= 0) + { + tran.RollbackTran(); + result.resultCode = 6; + result.resultMsg = $"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛紙缁戝畾锛夊け璐ワ紝{model.startLoc}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + if (db.Insertable<TN_Task>(task1).ExecuteCommand() > 0 && + db.Updateable<TN_Location>(startLoc).ExecuteCommand() > 0 && + db.Updateable<TN_Location>(endLoc).ExecuteCommand() > 0) + { + + Task task99 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "浜哄伐娆″搧鍥炵倝", locCnt.S_CNTR_CODE); + }); + + + tran.CommitTran(); + result.resultCode = 0; + result.resultMsg = "鎴愬姛"; + LogHelper.Info($"鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟鎴愬姛锛屽鍣細{model.rfId}锛岃捣鐐癸細{model.startLoc}锛岀粓鐐癸細{endLoc.S_CODE}"); + return result; + } + else + { + tran.RollbackTran(); + result.resultCode = 7; + result.resultMsg = $"鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟澶辫触锛屽鍣細{model.rfId}锛岃捣鐐癸細{model.startLoc}锛岀粓鐐癸細{endLoc.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + } + catch(Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + /// <summary> + /// 鏄剧ず婊℃墭缂撳瓨搴撳綋鍓嶈鏍肩殑鎵樼洏鏁伴噺 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static string ShowCntCountBySpe(ShowCntCountBySpeInfo model) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + //鏌ヨ绗﹀悎瑙勬牸鐨勭墿鏂欐墍鍦ㄧ殑鏈攣瀹氬凡鍚敤鎸囧畾璐у尯鐨勮揣浣嶏紝璧风偣 + var allCg = db.Queryable<TN_CG_Detail>(). + LeftJoin<TN_Loc_Container>((o, i) => o.S_CNTR_CODE == i.S_CNTR_CODE). + LeftJoin<TN_Location>((o, i, s) => i.S_LOC_CODE == s.S_CODE). + Where((o, i, s) => s.N_CURRENT_NUM > 0 && s.S_AREA_CODE == Settings.Areas[1] && s.N_LOCK_STATE == 0 && s.S_LOCK_STATE == "鏃� && s.C_ENABLE == "Y" + && (o.S_ITEM_SPEC == model.Spe || o.S_SPE == model.Spe)).//鎸囧畾瑙勬牸 + ToList();//绛涢�鏈夊鍣ㄨ揣浣嶅叧绯昏〃淇℃伅锛岀瓫閫夋湁瀹瑰櫒璐у搧鏄庣粏琛ㄤ俊鎭�+ + var allCount = allCg.Count; + var waittime = SpecHelper.GetExportTime(model.Spe); + var okCount = allCg.Count(o => o.N_ITEM_STATE == 0 && o.S_ITEM_STATE == "鍚堟牸" && o.T_MODIFY.AddMinutes(waittime) <= System.DateTime.Now); + return $"婊¤冻{model.Spe}瑙勬牸鐨勬�鎵樼洏鏁伴噺锛歿allCount}锛屽叾涓悎鏍间笖闈欑疆鏃堕棿宸茶繃鐨勬墭鐩樻暟閲忥細{okCount}"; + } + catch (Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯革細{ex.Message}"); + return $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + } + } + + /// <summary> + /// 鎺ユ敹宸ュ崟淇℃伅 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + //internal static SimpleResult ReceiveWorkOrder(WorkOrderInfo model) + //{ + // string modelstr = JsonConvert.SerializeObject(model); + // LogHelper.Info("瑙﹀彂API锛氭帴鏀跺伐鍗曚俊鎭� + modelstr, "API"); + + // var result = new SimpleResult();//杩斿洖缁撴灉 + + // var db = new SqlHelper<object>().GetInstance(); + + // try + // { + // //鏌ヨ鏄惁鏈夎繖涓搴攊d鐨勫伐鍗� + // var modelWO = db.Queryable<TN_WorkOrder>().First(a => a.S_WORK_NO == model.S_WORK_NO); + // //鏄惁鏈夎繖涓骇绾�+ // var plInfo = Settings.ProductionLines.FirstOrDefault(a => a.ProductionLine_AreaCode == model.S_LINE_NO); + + // if (plInfo == null)//涓嶅瓨鍦ㄧ殑浜х嚎 + // { + // result.resultCode = 1; + // result.resultMsg = $"涓嶅瓨鍦ㄦ垨鏈綍鍏ョ殑浜х嚎{model.S_LINE_NO}"; + // LogHelper.Info(result.resultMsg); + // return result; + // } + + // if (modelWO != null)//閲嶅宸ュ崟涓嶆彃鍏�+ // { + // result.resultCode = 2; + // result.resultMsg = $"宸ュ崟宸叉敹鍒版棤娉曢噸澶嶆彃鍏ユ宸ュ崟{modelWO.S_WORK_NO}"; + // LogHelper.Info(result.resultMsg); + // return result; + // } + + // //TODO modelQuery宸ュ崟灞炴�璧嬪� + // modelWO = new TN_WorkOrder() + // { + // S_WORK_NO = model.S_WORK_NO, + // S_LINE_NO = model.S_LINE_NO, + // S_ITEM_CODE = model.S_ITEM_CODE, + // S_B_STATE = "鏂板缓", + // S_BATCH_NO = model.S_BATCH_NO, + // S_ITEM_SPEC = model.S_ITEM_SPEC, + // }; + + // string modelWOstr = JsonConvert.SerializeObject(modelWO); + + // if (db.Insertable<TN_WorkOrder>(modelWO).ExecuteCommand() > 0) //鎻掑叆宸ュ崟 + // { + // result.resultCode = 0; + // result.resultMsg = $"鏀跺埌宸ュ崟寮�鎵ц{modelWO.S_WORK_NO}"; + // LogHelper.Info(result.resultMsg); + // return result; + // } + // else + // { + // result.resultCode = 3; + // result.resultMsg = $"宸ュ崟鎻掑叆澶辫触{modelWO.S_WORK_NO}"; + // LogHelper.Info(result.resultMsg); + // return result; + // } + + // } + // catch (Exception ex) + // { + // result.resultCode = -1; + // result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + // LogHelper.Info(result.resultMsg); + // return result; + // } + + //} + + /// <summary> + /// 缁戝畾瀹瑰櫒鐢熶骇杞︽暟淇℃伅 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + //internal static SimpleResult CarNumBind(BindInfo model) + //{ + // LogHelper.Info("瑙﹀彂API锛氱粦瀹氬鍣ㄧ敓浜ц溅鏁颁俊鎭� + JsonConvert.SerializeObject(model), "API"); + + // var result = new SimpleResult(); + // //鏌ヨ鑰�+ // var db = new SqlHelper<object>().GetInstance(); + + // try + // { + // if (model.CarNum > 0) + // { + // //鏌ヨ绗﹀悎瑕佹眰 + // var modelCA = db.Queryable<TN_CAR_IN>().First(b => b.S_CNTR_CODE == model.RFID); + + // if (modelCA == null)//娌℃湁鎵惧埌璇ユ潯鏁版嵁锛屽彲浠ユ彃鍏�+ // { + // TN_CAR_IN carIn = new TN_CAR_IN(); + // carIn.S_CNTR_CODE = model.RFID; + // carIn.S_CAR_CODE = model.CarNum; + // int count = db.Insertable<TN_CAR_IN>(carIn).ExecuteCommand();//鎻掑叆瀛愯〃 + // if (count > 0) + // { + // result.resultCode = 0; + // result.resultMsg = $"缁戝畾鎴愬姛{model.RFID}"; + // LogHelper.Info(result.resultMsg); + // } + // else + // { + // result.resultCode = 2; + // result.resultMsg = $"缁戝畾鏁版嵁鎻掑叆澶辫触{model.RFID}"; + // LogHelper.Info(result.resultMsg); + // } + // } + // else + // { //鏈夎杞︽暟锛屾洿鏂�+ // modelCA.S_CNTR_CODE = model.RFID; + // modelCA.S_CAR_CODE = model.CarNum; + // int count = db.Updateable<TN_CAR_IN>(modelCA).ExecuteCommand();//鏇存柊瀛愯〃 + // if (count > 0) + // { + // result.resultCode = 0; + // result.resultMsg = $"缁戝畾鎴愬姛{model.RFID}"; + // LogHelper.Info(result.resultMsg); + // } + // else + // { + // result.resultCode = 3; + // result.resultMsg = $"缁戝畾鏁版嵁鏇存柊澶辫触{model.RFID}"; + // LogHelper.Info(result.resultMsg); + // } + // } + // } + // else + // { + // result.resultCode = 7; + // result.resultMsg = $"缁戝畾澶辫触锛屼紶杈撶殑淇℃伅涓嶈兘涓虹┖{JsonConvert.SerializeObject(model)}"; + // LogHelper.Info(result.resultMsg); + // } + // return result; + // } + // catch (Exception ex) + // { + // result.resultCode = -1; + // result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + // LogHelper.Info(result.resultMsg); + // return result; + // } + //} + + + /// <summary> + /// PDA婊℃墭涓嬬嚎鍏ュ簱鍛煎彨 + /// </summary> + internal static SimpleResult PDAFullInArea(PDAFullInAreaInfo model) + { + var db = new SqlHelper<object>().GetInstance(); + var result = new SimpleResult();//杩斿洖缁撴灉 + LogHelper.Info("瑙﹀彂API锛歅DA婊℃墭涓嬬嚎鍏ュ簱" + JsonConvert.SerializeObject(model), "API"); + try + { + //璇ヤ骇绾跨殑婊℃墭涓嬬嚎浣嶇疆锛岃捣鐐�+ var startPoint = Settings.ProductionLines.FirstOrDefault(a => a.PointOut == model.StartLoc); + if (startPoint != null)//璧风偣瀛樺湪 + { + var woInfo = db.Queryable<TN_WorkOrder>().Where(a => a.S_LINE_NO == startPoint.ProductionLine_Name && a.S_B_STATE == "寮�惎").OrderBy(b => b.T_CREATE, OrderByType.Desc).First(); + + if (woInfo != null)//褰撳墠浜х嚎涓嶅瓨鍦ㄥ紑鍚殑鏈�柊鐨勫伐鍗�+ { + var startLoc = db.Queryable<TN_Location>().First(a => a.S_LOCK_STATE == "鏃� && a.N_LOCK_STATE == 0 && a.S_CODE == model.StartLoc && a.C_ENABLE == "Y"); + if (startLoc != null)//璇ヤ骇绾跨殑璧风偣娌¢攣浣�+ { + var cgInfo = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == model.RfId); + if (cgInfo != null)//鏈夋畫鐣欑殑瀹瑰櫒璐у搧鏄庣粏鍏崇郴琛ㄤ俊鎭�+ { + result.resultCode = 1; + result.resultMsg = $"璇ュ鍣▄model.RfId}宸茬粦瀹氳揣鍝亄cgInfo.S_ITEM_CODE}锛屽鏋滆浣跨敤锛屽鍣ㄥ厛瑙g粦璐у搧"; + LogHelper.Info(result.resultMsg); + return result; + } + else + { + var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.RfId); + if (locCntrRel != null)//褰撳墠瀹瑰櫒鏄惁缁戝畾浜嗚揣浣�+ { + result.resultCode = 2; + result.resultMsg = $"璇ュ鍣▄model.RfId}宸茬粦瀹氳揣浣峽locCntrRel.S_LOC_CODE}锛屽鏋滆浣跨敤锛屽鍣ㄥ厛瑙g粦璐т綅"; + LogHelper.Info(result.resultMsg); + return result; + } + else + { + //鏂板璐т綅瀹瑰櫒鍏崇郴琛�+ locCntrRel = new TN_Loc_Container() + { + S_LOC_CODE = startPoint.PointOut, + S_CNTR_CODE = model.RfId, + }; + + var readBytes1 = S7Helper.ReadBytes(startPoint.ProductionLine_IP, 20, 2, 4); + byte[] rfid = new byte[4] { readBytes1[0], readBytes1[1], readBytes1[2], readBytes1[3] }; + string rfids16 = BitConverter.ToString(rfid); + string rfids = (((readBytes1[0]) << 24) + (readBytes1[1] << 16) + (readBytes1[2] << 8) + readBytes1[3]).ToString(); + LogHelper.Info($"浜х嚎瀹瑰櫒鍙凤細{rfids}锛屽叾16杩涘埗褰㈠紡锛歿rfids16}"); + + if (rfids != model.RfId) + { + result.resultCode = 9; + result.resultMsg = $"PDA濉叆鐨勫鍣ㄥ彿{model.RfId}涓嶴7浜х嚎閫氳鐨勫鍣ㄥ彿{rfids}涓嶅悓"; + LogHelper.Info(result.resultMsg); + return result; + } + var readBytes2 = S7Helper.ReadBytes(startPoint.ProductionLine_IP, 20, 26, 2); + var modelWeight = ((readBytes2[0]) << 8) + readBytes2[1]; + + var modelCI = db.Queryable<TN_CAR_IN>().First(i => i.S_CAR_CODE == model.CarCode && i.S_CNTR_CODE == model.RfId && i.S_B_STATE == "0");//鏌ヨ鏄惁鏈夎繖涓搴旂殑涓旂姸鎬佹甯哥殑瀹瑰櫒杞﹀彿瀛愯〃 + + TN_CG_Detail tN_CG_Detail = new TN_CG_Detail()//鏂板瀹瑰櫒璐у搧鏄庣粏琛�+ { + S_CNTR_CODE = model.RfId, + S_ITEM_CODE = woInfo.S_ITEM_CODE, + S_BATCH_NO = woInfo.S_BATCH_CODE, + S_ITEM_SPEC = woInfo.S_ITEM_SPEC, + S_SPE= woInfo.S_ITEM_SPEC, + S_CAR_CODE = model.CarCode, + N_ITEM_STATE = 1, + S_ITEM_STATE = "寰呮", + F_QTY = modelWeight,//杩欓噷鐨勯噸閲忚褰撴垚鏁伴噺鏉ヤ娇鐢�+ }; + + var endLoc = db.Queryable<TN_Location>(). + Where(c => c.S_AREA_CODE == Settings.Areas[1] && c.S_LOCK_STATE == "鏃� && c.N_LOCK_STATE == 0 && c.N_CURRENT_NUM == 0 && c.C_ENABLE == "Y"). + OrderBy(o => o.T_MODIFY, OrderByType.Asc).First();//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣嶏紝鐩存帴鍒ゆ柇褰撳墠鏁伴噺涓�鍗冲彲 + + if (endLoc != null) + { + var task1 = new TN_Task() + { + S_CODE = WCSHelper.GenerateTaskNo(), + S_START_AREA = startLoc.S_AREA_CODE, + S_END_AREA = endLoc.S_AREA_CODE, + S_START_LOC = startLoc.S_CODE, + S_END_LOC = endLoc.S_CODE, + S_TYPE = "PDA婊℃墭涓嬬嚎鍏ュ簱", + N_B_STATE = 0, + S_CNTR_CODE = model.RfId, + S_SPEC = model.Spe, + }; + + startLoc.N_LOCK_STATE = 2; + startLoc.S_LOCK_STATE = "鍑哄簱閿�; + startLoc.N_CURRENT_NUM = 1; + startLoc.T_MODIFY = DateTime.Now; + + endLoc.N_LOCK_STATE = 1; + endLoc.S_LOCK_STATE = "鍏ュ簱閿�; + startLoc.T_MODIFY = DateTime.Now; + + using (var tran = db.Ado.UseTran()) + { + if (modelCI == null)//瀹瑰櫒杞﹀彿瀛愯〃涓嶅瓨鍦�+ { + modelCI = new TN_CAR_IN() + { + S_CNTR_CODE = model.RfId, + S_CAR_CODE = model.CarCode, + S_B_STATE = "0", + }; + if (db.Insertable<TN_CAR_IN>(modelCI).ExecuteCommand() <= 0) + { + tran.RollbackTran(); + result.resultCode = 8; + result.resultMsg = $"鏂板鐨凾N_CAR_IN琛ㄦ彃鍏ュけ璐ワ紝瀹瑰櫒锛歿modelCI.S_CNTR_CODE}锛岃溅鍙凤細{modelCI.S_CAR_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + if (db.Insertable<TN_Task>(task1).ExecuteCommand() > 0 && + db.Updateable<TN_Location>(startLoc).ExecuteCommand() > 0 && + db.Updateable<TN_Location>(endLoc).ExecuteCommand() > 0 && + db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() > 0 && + db.Insertable<TN_CG_Detail>(tN_CG_Detail).ExecuteCommand() > 0)//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + tran.CommitTran(); + result.resultCode = 0; + result.resultMsg = "鎴愬姛"; + LogHelper.Info($"鐢熸垚PDA婊℃墭涓嬬嚎鍏ュ簱浠诲姟鎴愬姛锛屽鍣細{modelCI.S_CNTR_CODE}锛岃捣鐐癸細{startPoint.PointOut}锛岀粓鐐癸細{endLoc.S_CODE}"); + + Task task99 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "PDA婊℃墭涓嬬嚎鍏ュ簱", modelCI.S_CNTR_CODE); + }); + + Task task98 = Task.Run(() => + { + var target = new TN_EquipProDetail() + { + S_ID = tN_CG_Detail.S_ID, + TaskType = "PDA婊℃墭涓嬬嚎鍏ュ簱", + RFID = model.RfId, + Spec = woInfo.S_ITEM_SPEC, + CarCode = model.CarCode, + Weight = modelWeight, + ItemState = "寰呮", + ItemCode = woInfo.S_ITEM_CODE, + LoginName = model.staff, + Shift = "None", + StartLoc = startLoc.S_CODE, + }; + SpecHelper.InsertEquipProDetail(target); + }); + + Task task27 = Task.Run(() => + { + var target = new TN_InventoryM() + { + S_ID = tN_CG_Detail.S_ID, + RFID = model.RfId, + Spec = woInfo.S_ITEM_SPEC, + Weight = modelWeight, + ItemState = "寰呮", + ItemCode = woInfo.S_ITEM_CODE, + LoginName = model.staff, + Shift = "None", + }; + SpecHelper.InsertInventoryM(target); + }); + + return result; + } + else + { + tran.RollbackTran(); + result.resultCode = 7; + result.resultMsg = $"鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟澶辫触锛屽鍣細{modelCI.S_CNTR_CODE}锛岃捣鐐癸細{startPoint.PointOut}锛岀粓鐐癸細{endLoc.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + } + else + { + result.resultCode = 4; + result.resultMsg = $"鏈壘鍒板悎閫傜殑缁堢偣锛屽鍣細{modelCI.S_CNTR_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + } + } + else + { + result.resultCode = 9; + result.resultMsg = $"姝や綅缃細{startPoint.PointOut}宸查攣浣�; + LogHelper.Info(result.resultMsg); + return result; + } + } + else + { + result.resultCode = 10; + result.resultMsg = $"褰撳墠浜х嚎{startPoint.ProductionLine_Name}浣嶇疆{startPoint.PointOut}娌℃湁寮�惎鐨勫伐鍗�; + LogHelper.Info(result.resultMsg); + return result; + } + } + else + { + result.resultCode = 11; + result.resultMsg = $"鏈壘鍒拌璧风偣锛歿model.StartLoc}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + catch (Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯竰ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + /// <summary> + /// 鏇存柊鐗╂枡鏄庣粏鐨勭姸鎬侊紝0鍚堟牸1寰呮2涓嶅悎鏍硷紝涓嬬嚎鍗冲緟妫�+ /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult UpCgDetailModel(UpCgDetailModel model) + { + LogHelper.Info("瑙﹀彂API锛氭洿鏂扮墿鏂欐槑缁嗙殑鐘舵�" + JsonConvert.SerializeObject(model), "API"); + + var result = new SimpleResult();//杩斿洖缁撴灉 + var db = new SqlHelper<object>().GetInstance(); + + try + { + var cG_Detail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == model.cntID); + if (cG_Detail != null) + { + cG_Detail.N_ITEM_STATE = model.state; + cG_Detail.S_ITEM_STATE = model.stateInfo; + cG_Detail.T_MODIFY = System.DateTime.Now; + if (db.Updateable<TN_CG_Detail>(cG_Detail).UpdateColumns(it => new { it.N_ITEM_STATE, it.S_ITEM_STATE, it.T_MODIFY }).ExecuteCommand() > 0) + { + result.resultCode = 0; + result.resultMsg = "鎴愬姛"; + LogHelper.Info(result.resultMsg); + + Task task99 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "鏇存柊鐗╂枡鏄庣粏鐘舵�", model.cntID); + }); + } + else + { + result.resultCode = 1; + result.resultMsg = "鏇存柊澶辫触"; + LogHelper.Info(result.resultMsg); + } + } + else + { + result.resultCode = 2; + result.resultMsg = "鏈壘鍒拌鐗╂枡淇℃伅"; + LogHelper.Info(result.resultMsg); + } + + return result; + } + catch (Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + /// <summary> + /// 婊℃墭鍑哄簱涓婄嚎 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult FullOutWarehouse(FullOutWarehouseInfo model) + { + LogHelper.Info("瑙﹀彂API锛氭弧鎵樺嚭搴撲笂绾� + JsonConvert.SerializeObject(model), "API"); + + var result = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + TN_Location endLoc = new TN_Location(); + try + { + if (model.EndLoc != string.Empty)//鎸囧畾缁堢偣璐т綅 + { + endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.EndLoc); + + if (endLoc == null) + { + result.resultCode = 2; + result.resultMsg = $"鏈壘鍒扮粓鐐硅揣浣峽model.EndLoc}"; + LogHelper.Info(result.resultMsg); + return result; + } + + if (endLoc.S_AREA_CODE != Settings.Areas[2]) + { + result.resultCode = 3; + result.resultMsg = $"璇ョ粓鐐硅揣浣峽model.EndLoc}涓嶅湪绾胯竟鍖簕Settings.Areas[2]}"; + LogHelper.Info(result.resultMsg); + return result; + } + + if (endLoc.N_LOCK_STATE != 0 || endLoc.S_LOCK_STATE != "鏃� || endLoc.C_ENABLE != "Y") + { + result.resultCode = 4; + result.resultMsg = $"璇ョ粓鐐硅揣浣峽model.EndLoc}鏈В閿�; + LogHelper.Info(result.resultMsg); + return result; + } + + if (endLoc.N_CURRENT_NUM != 0) + { + result.resultCode = 5; + result.resultMsg = $"璇ョ粓鐐硅揣浣峽model.EndLoc}宸叉弧"; + LogHelper.Info(result.resultMsg); + return result; + } + } + else//鏈寚瀹�+ { + result.resultCode = 6; + result.resultMsg = $"缁堢偣璐т綅鍙傛暟涓嶈兘涓虹┖"; + LogHelper.Info(result.resultMsg); + return result; + } + + var waitTime = SpecHelper.GetWaitTime(model.Spe); + + //鏌ヨ绗﹀悎瑙勬牸鐨勭墿鏂欐墍鍦ㄧ殑鏈攣瀹氬凡鍚敤鎸囧畾璐у尯鐨勮揣浣嶏紝璧风偣 + var startLoc = db.Queryable<TN_Location>(). + LeftJoin<TN_Loc_Container>((o, i) => o.S_CODE == i.S_LOC_CODE). + LeftJoin<TN_CG_Detail>((o, i, s) => i.S_CNTR_CODE == s.S_CNTR_CODE). + Where((o, i, s) => o.N_CURRENT_NUM > 0 && o.S_AREA_CODE == Settings.Areas[1] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.C_ENABLE == "Y" + && (s.S_ITEM_SPEC == model.Spe || s.S_SPE == model.Spe)//鎸囧畾瑙勬牸 + && s.N_ITEM_STATE == 0 && s.S_ITEM_STATE == "鍚堟牸" //鍚堟牸鐨�+ && s.T_MODIFY.AddMinutes(waitTime) <= System.DateTime.Now).//鏍规嵁瑙勬牸鐨勪笉鍚岄潤缃笉鍚屽垎閽熸墠鑳藉嚭搴�+ OrderBy((o, i, s) => s.T_CREATE, OrderByType.Asc).//鍏堣繘鍏堝嚭 + First();//绛涢�鏈夊鍣ㄨ揣浣嶅叧绯昏〃淇℃伅锛岀瓫閫夋湁瀹瑰櫒璐у搧鏄庣粏琛ㄤ俊鎭�+ + if (startLoc == null) + { + result.resultCode = 7; + result.resultMsg = $"鏈壘鍒板悎閫傜殑璧风偣璐т綅锛岄渶瑕佹弧瓒筹細灞炰簬{Settings.Areas[1]}鐨勶紝褰撳墠鏁伴噺澶т簬0鐨勶紝鏈攣瀹氱殑璐т綅锛屼笖鐗╂枡鏄庣粏琛ㄦ湁婊¤冻鏁伴噺S_SPE绛変簬{model.Spe}鐨勫悎鏍肩殑闈欑疆鏃堕棿瓒冲鐨勭墿鏂�; + LogHelper.Info(result.resultMsg); + return result; + } + + var container = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == startLoc.S_CODE).S_CNTR_CODE;//鏍规嵁璧风偣璐т綅鎵惧埌瀹瑰櫒 + if (container == string.Empty) + { + result.resultCode = 8; + result.resultMsg = $"璐т綅瀹瑰櫒鍏崇郴琛ㄦ湭鎵惧埌璧风偣{startLoc.S_CODE}鐨勫鍣ㄥ彿"; + LogHelper.Info(result.resultMsg); + return result; + } + + var cgInfo = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == container); + + + //鍒涘缓婊℃墭鍑哄簱涓婄嚎浠诲姟 + if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "婊℃墭鍑哄簱涓婄嚎", 3, container,out string taskNo, cgInfo.S_SPE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ LogHelper.Info($"鐢熸垚婊℃墭鍑哄簱涓婄嚎浠诲姟鎴愬姛锛屽鍣ㄥ彿{container}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"); + + Task task1 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "婊℃墭鍑哄簱涓婄嚎", container); + }); + + Task task2 = Task.Run(() => + { + var target = new TN_Component_Detail() + { + ItemCode = cgInfo.S_ITEM_CODE, + CntrCode = container, + EndLoc = endLoc.S_CODE, + Staff = model.staff, + Weight = cgInfo.F_QTY, + Spec = model.Spe, + TaskNo = taskNo, + }; + SpecHelper.InsertComponentDetail(target); + }); + } + else + { + result.resultCode = 9; + result.resultMsg = $"鐢熸垚婊℃墭鍑哄簱涓婄嚎浠诲姟澶辫触锛屽鍣ㄥ彿{container}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + catch (Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + return result; + } + + /// <summary> + /// 绌烘墭涓嬬嚎鍫嗗彔锛堝彧缁戝畾璐т綅瀹瑰櫒涓嶅垱寤轰换鍔★級 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult EmptyInStackArea(EmptyInStackAreaInfo model) + { + LogHelper.Info("瑙﹀彂API锛氱┖鎵樹笅绾垮爢鍙� + JsonConvert.SerializeObject(model), "API"); + + + var result = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + TN_Location startLoc = new TN_Location(); + + try + { + var startLocCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.startLoc && a.S_CNTR_CODE == model.cntID); + if (startLocCntrRel != null) + { + result.resultCode = 1; + result.resultMsg = $"璐т綅{model.startLoc}宸茬粦瀹氬鍣▄model.cntID}"; + LogHelper.Info(result.resultMsg); + return result; + } + + var cG_Detail = db.Queryable<TN_CG_Detail>().Where(a => a.S_CNTR_CODE == model.cntID).ToList(); + if (cG_Detail.Count > 0)//闃叉鐜板疄涓湭娓呯┖璐у搧鑰岀洿鎺ヨ皟鐢�+ { + result.resultCode = 2; + result.resultMsg = $"瀹瑰櫒{model.cntID}鏈В缁戣揣鍝�; + LogHelper.Info(result.resultMsg); + return result; + } + + startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc); + + if (startLoc == null) + { + result.resultCode = 7; + result.resultMsg = $"璐т綅{model.startLoc}涓嶅瓨鍦�; + LogHelper.Info(result.resultMsg); + return result; + } + + if (startLoc.N_CURRENT_NUM > 0) + { + result.resultCode = 3; + result.resultMsg = $"璐т綅{model.startLoc}宸茬粦瀹氬鍣紝鏃犳硶鍐嶆缁戝畾"; + LogHelper.Info(result.resultMsg); + return result; + } + + if (startLoc.S_AREA_CODE != Settings.Areas[6]) + { + result.resultCode = 4; + result.resultMsg = $"绌烘墭{model.cntID}璐т綅{startLoc.S_CODE}鎵�湪鍖哄煙涓嶄负浜哄伐绌烘墭鍖�; + LogHelper.Info(result.resultMsg); + return result; + } + + if (startLoc.N_LOCK_STATE != 0 || startLoc.S_LOCK_STATE != "鏃�) + { + result.resultCode = 5; + result.resultMsg = $"璐т綅{startLoc.S_CODE}鏈В閿�; + LogHelper.Info(result.resultMsg); + return result; + } + + if (LocationHelper.BindingLoc(model.startLoc, new List<string>() { model.cntID }).Contains("鎴愬姛")) + { + result.resultCode = 0; + result.resultMsg = "鎴愬姛"; + LogHelper.Info($"璐т綅{startLoc.S_CODE}缁戝畾瀹瑰櫒{model.cntID}鎴愬姛"); + + Task task1 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "绌烘墭涓嬬嚎鍫嗗彔", model.cntID); + }); + + return result; + } + else + { + result.resultCode = 6; + result.resultMsg = $"璐т綅{startLoc.S_CODE}缁戝畾瀹瑰櫒{model.cntID}澶辫触"; + LogHelper.Info(result.resultMsg); + return result; + } + } + catch (Exception ex) + { + result.resultCode = 1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + + /// <summary> + /// 浣欐枡涓嬬嚎鍏ュ簱 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult SurplusInWarehouse(InWarehouseInfo model) + { + + LogHelper.Info("瑙﹀彂API锛氫綑鏂欎笅绾垮叆搴� + JsonConvert.SerializeObject(model), "API"); + + var result = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + TN_Location startLoc_Old = new TN_Location(); + TN_Location startLoc_New = new TN_Location(); + + try + { + + var cG_Detail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == model.cntID); + if (cG_Detail == null) + { + result.resultCode = 7; + result.resultMsg = $"瀹瑰櫒{model.cntID}宸叉竻绌鸿揣鍝�; + LogHelper.Info(result.resultMsg); + return result; + } + + var startLocCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.cntID); + if (startLocCntrRel == null) + { + result.resultCode = 2; + result.resultMsg = $"瀹瑰櫒{ model.cntID}鏈壘鍒拌揣浣嶄俊鎭紝"; + LogHelper.Info(result.resultMsg); + return result; + } + startLoc_Old = db.Queryable<TN_Location>().First(a => a.S_CODE == startLocCntrRel.S_LOC_CODE); + + if (startLoc_Old == null) + { + result.resultCode = 3; + result.resultMsg = $"鏈壘鍒版棫鐨勮揣浣嶄俊鎭瘂startLocCntrRel.S_LOC_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + + if (startLoc_Old.N_LOCK_STATE != 0 || startLoc_Old.S_LOCK_STATE != "鏃� || startLoc_Old.C_ENABLE != "Y") + { + result.resultCode = 5; + result.resultMsg = $"鏃х殑璐т綅{startLoc_Old.S_CODE}鏈В閿�; + LogHelper.Info(result.resultMsg); + return result; + } + + startLoc_New = db.Queryable<TN_Location>().First(a => a.S_CODE == model.startLoc && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.S_AREA_CODE == Settings.Areas[10]); + + if (startLoc_New == null) + { + result.resultCode = 8; + result.resultMsg = $"鏂扮殑璧风偣璐т綅{model.startLoc}鍦▄Settings.Areas[10]}鏈В閿�; + LogHelper.Info(result.resultMsg); + return result; + } + + if (startLoc_New.S_CODE != startLoc_Old.S_CODE && startLoc_New.N_CURRENT_NUM > 0) + { + result.resultCode = 9; + result.resultMsg = $"鏂扮殑璧风偣璐т綅{model.startLoc}鍦▄Settings.Areas[10]}鏈夊叾浠栬揣鍝�; + LogHelper.Info(result.resultMsg); + return result; + } + + var weightPoint = Settings.WeightDevices[0]?.Point ?? "Null"; + + if (db.Queryable<TN_Task>().Count(a => a.N_B_STATE < 3 && a.S_END_LOC == weightPoint) > 2) + { + result.resultCode = 11; + result.resultMsg = $"缁堢偣绉伴噸璐т綅{weightPoint}鐨勬鍦ㄦ墽琛岀殑浠诲姟鏁伴噺澶т簬2"; + LogHelper.Info(result.resultMsg); + return result; + } + + //鏌ヨ绗﹀悎鐨勬湭閿佸畾宸插惎鐢ㄦ寚瀹氳揣鍖虹殑璐т綅锛岀粓鐐�+ var endLoc = db.Queryable<TN_Location>(). + First(o => o.S_AREA_CODE == Settings.Areas[9] && o.S_CODE == weightPoint && o.C_ENABLE == "Y");//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣�+ + if (endLoc == null) + { + result.resultCode = 6; + result.resultMsg = $"瀹瑰櫒{ model.cntID}璐т綅{startLoc_Old.S_CODE}鏈壘鍒板悎閫傜殑缁堢偣"; + LogHelper.Info(result.resultMsg); + return result; + } + + //鎹㈢粦 + startLoc_Old.N_CURRENT_NUM = 0; + db.Updateable<TN_Location>(startLoc_Old).UpdateColumns(it => new { it.N_CURRENT_NUM }).ExecuteCommand(); + startLocCntrRel.S_LOC_CODE = model.startLoc; + db.Updateable<TN_Loc_Container>(startLocCntrRel).UpdateColumns(it => new { it.S_LOC_CODE }).ExecuteCommand(); + startLoc_New.N_CURRENT_NUM = 1; + db.Updateable<TN_Location>(startLoc_New).UpdateColumns(it => new { it.N_CURRENT_NUM }).ExecuteCommand(); + + //鍒涘缓浣欐枡涓嬬嚎鍏ュ簱浠诲姟锛岀涓�樁娈�+ if (WCSHelper.CreateTask(startLoc_New.S_CODE, endLoc.S_CODE, "浣欐枡涓嬬嚎鍏ュ簱", 3, model.cntID,out string taksNo,cG_Detail.S_SPE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc_New.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ LogHelper.Info($"鐢熸垚浣欐枡涓嬬嚎鍏ュ簱浠诲姟鎴愬姛锛屽鍣ㄥ彿{model.cntID}锛岃捣鐐箋startLoc_Old.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"); + + Task task1 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "浣欐枡涓嬬嚎鍏ュ簱", model.cntID); + }); + + Task task2 = Task.Run(() => + { + var target = new TN_SurplusDetail() + { + CntCode = model.cntID, + StartLoc = startLoc_New.S_CODE, + LoginName = model.staff, + ItemCode = cG_Detail.S_ITEM_CODE, + Spec = cG_Detail.S_SPE, + CarCode = cG_Detail.S_CAR_CODE, + Weight = cG_Detail.F_QTY, + RemeltTime = DateTime.Now, + TaskNo = taksNo + }; + SpecHelper.InsertSurplusDetail(target); + }); + } + else + { + result.resultCode = 10; + result.resultMsg = $"鐢熸垚浣欐枡涓嬬嚎鍏ュ簱浠诲姟澶辫触锛屽鍣ㄥ彿{model.cntID}锛岃捣鐐箋startLoc_Old.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + catch (Exception ex) + { + result.resultCode = 1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + return result; + } + + /// <summary> + /// 浜哄伐鎷嗙洏鍑哄簱 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult SplitOutWarehouse(SplitOutWarehouseInfo model) + { + LogHelper.Info("瑙﹀彂API锛氫汉宸ユ媶鐩樺嚭搴� + JsonConvert.SerializeObject(model), "API"); + + var result = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + + try + { + var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.cntID); + if (locCntrRel == null) + { + result.resultCode = 2; + result.resultMsg = $"瀹瑰櫒鍙穥model.cntID}娌℃湁璐т綅瀹瑰櫒淇℃伅"; + LogHelper.Info(result.resultMsg); + return result; + } + var cG_Detail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCntrRel.S_CNTR_CODE); + if (cG_Detail == null) + { + result.resultCode = 3; + result.resultMsg = $"瀹瑰櫒{locCntrRel.S_CNTR_CODE}娌℃湁璐у搧"; + LogHelper.Info(result.resultMsg); + return result; + } + var startLoc = db.Queryable<TN_Location>().First(a => a.S_AREA_CODE == Settings.Areas[1] && a.S_CODE == locCntrRel.S_LOC_CODE && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y"); + if (startLoc == null) + { + result.resultCode = 4; + result.resultMsg = $"璧风偣璐т綅{locCntrRel.S_LOC_CODE}鏈В閿侊紝鎴栦笉灞炰簬{Settings.Areas[1]}"; + LogHelper.Info(result.resultMsg); + return result; + } + + TN_Location endLoc = new TN_Location(); + if (model.endLoc != string.Empty)//鎸囧畾缁堢偣 + { + endLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.endLoc); + + if (endLoc.S_AREA_CODE != Settings.Areas[5]) + { + result.resultCode = 5; + result.resultMsg = $"璇ョ粓鐐硅揣浣峽model.endLoc}涓嶅湪鎷嗙洏鍖簕Settings.Areas[5]}"; + LogHelper.Info(result.resultMsg); + return result; + } + + if (endLoc.N_CURRENT_NUM > 0) + { + result.resultCode = 6; + result.resultMsg = $"璇ョ粓鐐硅揣浣峽model.endLoc}鏈夎揣鍝佷俊鎭�; + LogHelper.Info(result.resultMsg); + return result; + } + + if (endLoc.N_LOCK_STATE != 0 || endLoc.S_LOCK_STATE != "鏃� || endLoc.C_ENABLE != "Y") + { + result.resultCode = 7; + result.resultMsg = $"璇ョ粓鐐硅揣浣峽model.endLoc}鏈В閿�; + LogHelper.Info(result.resultMsg); + return result; + } + } + else//鏈寚瀹氾紝闅忔満鏌ヨ鍚堥�缁堢偣璐т綅 + { + endLoc = db.Queryable<TN_Location>(). + Where(o => o.S_AREA_CODE == Settings.Areas[5] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.C_ENABLE == "Y" && o.N_CURRENT_NUM == 0). + OrderBy(o => o.T_MODIFY, OrderByType.Asc).First();//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣�+ + } + if (endLoc == null) + { + result.resultCode = 8; + result.resultMsg = $"瀹瑰櫒{locCntrRel.S_CNTR_CODE}鏈壘鍒板悎閫傜殑缁堢偣璐т綅"; + LogHelper.Info(result.resultMsg); + return result; + } + //鍒涘缓浜哄伐鎷嗙洏鍑哄簱浠诲姟 + if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "浜哄伐鎷嗙洏鍑哄簱", 3, locCntrRel.S_CNTR_CODE,cG_Detail.S_SPE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ LogHelper.Info($"鐢熸垚浜哄伐鎷嗙洏鍑哄簱浠诲姟鎴愬姛锛屽鍣ㄥ彿{locCntrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"); + + Task task1 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "浜哄伐鎷嗙洏鍑哄簱", model.cntID); + }); + } + else + { + result.resultCode = 9; + result.resultMsg = $"鐢熸垚浜哄伐鎷嗙洏鍑哄簱浠诲姟澶辫触锛屽鍣ㄥ彿{locCntrRel.S_CNTR_CODE}锛岃捣鐐箋startLoc.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + catch (Exception ex) + { + result.resultCode = 1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + return result; + } + + + /// <summary> + /// 浜哄伐鎷嗙洏鍏ュ簱 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult ResultInWarehouse(ResultInWarehouseInfo model) + { + LogHelper.Info("瑙﹀彂API锛氫汉宸ユ媶鐩樺叆搴� + JsonConvert.SerializeObject(model), "API"); + + var result = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + string cntLog = $"鏃х殑瀹瑰櫒鍙穥model.old_CntId}"; + try + { + if (model.new_IsOK == model.old_IsOK) + { + result.resultCode = 19; + result.resultMsg = $"浜哄伐鎷嗙洏鍏ュ簱锛岀墿鏂欓渶瑕佷竴涓悎鏍间竴涓笉鍚堟牸"; + LogHelper.Info(result.resultMsg); + return result; + } + + if (model.new_CntIds == model.old_CntId) + { + result.resultCode = 13; + result.resultMsg = $"鎷嗗嚭鐨勬墭鐩樹笉鑳戒笌瑕佹媶鐨勬墭鐩樹竴鏍�; + LogHelper.Info(result.resultMsg); + return result; + } + + if (model.old_StartLoc == model.new_StartLoc) + { + result.resultCode = 14; + result.resultMsg = $"鎷嗗嚭鐨勬墭鐩樼殑璧风偣涓嶈兘涓庤鎷嗙殑鎵樼洏鐨勮捣鐐逛竴鏍�; + LogHelper.Info(result.resultMsg); + return result; + } + + TN_CG_Detail cG_old_Detail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == model.old_CntId); + if (cG_old_Detail == null) + { + result.resultCode = 2; + result.resultMsg = $"鏈壘鍒拌鎷嗙殑瀹瑰櫒璐у搧鏄庣粏琛ㄤ俊鎭紝" + cntLog; + LogHelper.Info(result.resultMsg); + return result; + } + + var startLoc_Old = db.Queryable<TN_Location>(). + First(o => o.S_CODE == model.old_StartLoc && o.N_CURRENT_NUM == 0 && o.S_AREA_CODE == Settings.Areas[5] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃�); + + if (startLoc_Old == null) + { + result.resultCode = 4; + result.resultMsg = $"瑕佹媶鍒嗙殑鏃ф墭鐩樼殑璧风偣璐т綅{model.old_StartLoc}鏈В閿佹垨涓嶅睘浜庡尯鍩焮Settings.Areas[5]}"; + LogHelper.Info(result.resultMsg); LogHelper.Info(result.resultMsg); + return result; + } + + var startLoc_New = db.Queryable<TN_Location>(). + First(b => b.S_CODE == model.new_StartLoc && b.N_CURRENT_NUM == 0 && b.S_AREA_CODE == Settings.Areas[5] && b.N_LOCK_STATE == 0 && b.S_LOCK_STATE == "鏃�); + + + if (startLoc_New == null) + { + result.resultCode = 5; + result.resultMsg = $"鎷嗗垎鍚庣殑鏂版墭鐩樼殑璧风偣璐т綅{model.new_StartLoc}鏈В閿佹垨涓嶅睘浜庡尯鍩焮Settings.Areas[5]}"; + LogHelper.Info(result.resultMsg); LogHelper.Info(result.resultMsg); + return result; + } + + var locCntrRel_New1 = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.new_CntIds); + if (locCntrRel_New1 != null) + { + LocationHelper.ErrorLocCntReset(new ErrorLocCntResetInfo() { cntID = model.new_CntIds ,reqCode=2}); + result.resultCode = 6; + result.resultMsg = $"鎷嗗垎鍚庣殑鏂版墭鐩樺瓨鍦ㄦ畫鐣欑殑璐т綅瀹瑰櫒鍏崇郴琛紝宸茶В缁戦噸缃紝瀹瑰櫒鍙穥model.new_CntIds}锛岃揣浣峽locCntrRel_New1.S_LOC_CODE}"; + LogHelper.Info(result.resultMsg); + } + + var locCntrRel_Old1 = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.old_CntId); + if (locCntrRel_Old1 != null) + { + LocationHelper.ErrorLocCntReset(new ErrorLocCntResetInfo() { cntID = model.old_CntId, reqCode = 2 }); + result.resultCode = 6; + result.resultMsg = $"琚媶鐨勬棫鎵樼洏瀛樺湪娈嬬暀鐨勮揣浣嶅鍣ㄥ叧绯昏〃锛屽凡瑙g粦閲嶇疆锛屽鍣ㄥ彿{model.old_CntId}锛岃揣浣峽locCntrRel_Old1.S_LOC_CODE}"; + LogHelper.Info(result.resultMsg); + } + + locCntrRel_Old1 = new TN_Loc_Container() + { + S_LOC_CODE = model.old_StartLoc, + S_CNTR_CODE = model.old_CntId, + T_MODIFY = System.DateTime.Now + }; + + locCntrRel_New1 = new TN_Loc_Container() + { + S_LOC_CODE = model.new_StartLoc, + S_CNTR_CODE = model.new_CntIds, + T_MODIFY = System.DateTime.Now + }; + + cG_old_Detail.S_ITEM_STATE = LocationHelper.GetStrByOk(model.old_IsOK); + cG_old_Detail.N_ITEM_STATE = model.new_IsOK; + cG_old_Detail.S_Separate_ID = Guid.NewGuid().ToString("D"); + + var cG_new_Detail_Ins = new TN_CG_Detail() + { + S_CNTR_CODE = model.new_CntIds, + S_BATCH_NO = cG_old_Detail.S_BATCH_NO, + S_ITEM_SPEC = cG_old_Detail.S_ITEM_SPEC, + S_SPE = cG_old_Detail.S_SPE, + S_ITEM_STATE = LocationHelper.GetStrByOk(model.new_IsOK), + N_ITEM_STATE = model.new_IsOK, + S_CAR_CODE = cG_old_Detail.S_CAR_CODE, + T_MODIFY = System.DateTime.Now, + //C_ITEM_MERGE = model.new_CntIds, + S_ITEM_CODE = cG_old_Detail.S_ITEM_CODE, + S_Separate_ID = cG_old_Detail.S_Separate_ID + }; + + var weightPoint = Settings.WeightDevices[0]?.Point ?? "Null"; + + if (db.Queryable<TN_Task>().Count(a => a.N_B_STATE < 3 && a.S_END_LOC == weightPoint) > 2) + { + result.resultCode = 11; + result.resultMsg = $"缁堢偣绉伴噸璐т綅{weightPoint}鐨勬鍦ㄦ墽琛岀殑浠诲姟鏁伴噺澶т簬2"; + LogHelper.Info(result.resultMsg); + return result; + } + + var endLoc_Ok = db.Queryable<TN_Location>(). + First(o => o.S_AREA_CODE == Settings.Areas[9] && o.S_CODE == weightPoint);//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣嶏紝鍘荤О閲�+ + var endLoc_NG = db.Queryable<TN_Location>(). + First(o => o.S_AREA_CODE == Settings.Areas[8] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.N_CURRENT_NUM == 0);//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣�+ + if (endLoc_Ok == null) + { + result.resultCode = 10; + result.resultMsg = $"鍚堟牸鐨勭墿鏂欐湭鎵惧埌鍚堥�鐨勭О閲嶇粓鐐硅揣浣峽weightPoint}"; + LogHelper.Info(result.resultMsg); + return result; + } + + if (endLoc_NG == null) + { + result.resultCode = 16; + result.resultMsg = $"涓嶅悎鏍肩殑鐗╂枡鏈壘鍒板悎閫傜殑鍥炵倝鍖虹粓鐐硅揣浣峽Settings.Areas[8]}"; + LogHelper.Info(result.resultMsg); + return result; + } + + var taskLog1_Old = $"鏃у鍣ㄥ彿{model.old_CntId}锛屾棫瀹瑰櫒鍙风殑璧风偣{startLoc_Old.S_CODE}锛岀粓鐐箋endLoc_Ok.S_CODE}"; + + var taskLog_New = $"鏂板鍣ㄥ彿{model.new_CntIds}锛屾柊瀹瑰櫒鍙风殑璧风偣{model.new_StartLoc}锛岀粓鐐箋endLoc_NG.S_CODE}"; + + List<CreateTasks> modesCreateTask = new List<CreateTasks>(); + + var newTaskCreate = new CreateTasks() + { + taskNo = WCSHelper.GenerateTaskNo(), + from = model.new_StartLoc, + fromArea = startLoc_New.S_AREA_CODE, + to = (model.new_IsOK == 2) ? endLoc_NG.S_CODE : endLoc_Ok.S_CODE, + toArea = (model.new_IsOK == 2) ? endLoc_NG.S_AREA_CODE : endLoc_Ok.S_AREA_CODE, + taskType = (model.new_IsOK == 2) ? "浜哄伐鎷嗙洏鍥炵倝" : "浜哄伐鎷嗙洏鍥炲簱", + pri = 3, + cntrInfo = model.new_CntIds, + spec = cG_new_Detail_Ins.S_SPE, + }; + + modesCreateTask.Add(newTaskCreate); + + var oldTaskCreate = new CreateTasks() + { + taskNo = WCSHelper.GenerateTaskNo(), + from = startLoc_Old.S_CODE, + fromArea = startLoc_Old.S_AREA_CODE, + to = (model.old_IsOK == 2) ? endLoc_NG.S_CODE : endLoc_Ok.S_CODE, + toArea = (model.old_IsOK == 2) ? endLoc_NG.S_AREA_CODE : endLoc_Ok.S_AREA_CODE, + taskType = (model.old_IsOK == 2) ? "浜哄伐鎷嗙洏鍥炵倝" : "浜哄伐鎷嗙洏鍥炲簱", + pri = 3, + cntrInfo = model.old_CntId, + spec = cG_old_Detail.S_SPE, + }; + modesCreateTask.Add(oldTaskCreate); + + startLoc_Old.N_LOCK_STATE = 2; + startLoc_Old.S_LOCK_STATE = "鍑哄簱閿�; + startLoc_Old.N_CURRENT_NUM = 1; + + + startLoc_New.N_LOCK_STATE = 2; + startLoc_New.S_LOCK_STATE = "鍑哄簱閿�; + startLoc_New.N_CURRENT_NUM = 1; + + endLoc_Ok.N_LOCK_STATE = 1; + endLoc_Ok.S_LOCK_STATE = "鍏ュ簱閿�; + + using (var tran = db.Ado.UseTran()) + { + if (model.old_IsOK != 2 || model.new_IsOK != 2) + { + if (db.Updateable<TN_Location>(endLoc_Ok).ExecuteCommand()<=0) + { + tran.RollbackTran(); + result.resultCode = 12; + result.resultMsg = $"鐢熸垚浜哄伐鎷嗙洏鍏ュ簱浠诲姟澶辫触锛� + taskLog_New + taskLog1_Old; + LogHelper.Info(result.resultMsg); + return result; + } + } + + if ( + db.Updateable<TN_Location>(startLoc_Old).ExecuteCommand() > 0 && + db.Updateable<TN_Location>(startLoc_New).ExecuteCommand() > 0 && + db.Insertable<TN_Loc_Container>(locCntrRel_New1).ExecuteCommand() > 0 && + db.Insertable<TN_Loc_Container>(locCntrRel_Old1).ExecuteCommand() > 0 && + db.Updateable<TN_CG_Detail>(cG_old_Detail).ExecuteCommand() > 0 && + db.Insertable<TN_CG_Detail>(cG_new_Detail_Ins).ExecuteCommand()>0 + ) + { + //鍒涘缓浜哄伐鎷嗙洏鍏ュ簱浠诲姟锛屽悎鏍肩殑鐩樺洖鍘荤О閲嶏紝涓嶅悎鏍肩殑鍥炵倝锛屽嵆鍘讳笉鍚堟牸鍖�+ if (WCSHelper.CreateTask(modesCreateTask))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + tran.CommitTran(); + LogHelper.Info($"鐢熸垚浜哄伐鎷嗙洏鍏ュ簱浠诲姟鎴愬姛锛� + taskLog_New + taskLog1_Old); + + Task task1 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "浜哄伐鎷嗙洏鍏ュ簱", model.new_CntIds + "," + model.old_CntId); + }); + + Task task2 = Task.Run(() => + { + if (model.old_IsOK == 1) + { + var target = new TN_RemeltDetail() + { + TaskNo = oldTaskCreate.taskNo, + CntCode = cG_old_Detail.S_CNTR_CODE, + StartLoc = startLoc_Old.S_CODE, + LoginName = model.staff, + ItemCode = cG_old_Detail.S_ITEM_CODE, + Spec = cG_old_Detail.S_SPE, + CarCode = cG_old_Detail.S_CAR_CODE, + Weight = cG_old_Detail.F_QTY, + RemeltTime = DateTime.Now + }; + SpecHelper.InsertRemeltDetail(target); + } + if (model.new_IsOK == 1) + { + var target = new TN_RemeltDetail() + { + TaskNo = newTaskCreate.taskNo, + CntCode = cG_new_Detail_Ins.S_CNTR_CODE, + StartLoc = startLoc_New.S_CODE, + LoginName = model.staff, + ItemCode = cG_new_Detail_Ins.S_ITEM_CODE, + Spec = cG_new_Detail_Ins.S_SPE, + CarCode = cG_new_Detail_Ins.S_CAR_CODE, + Weight = cG_new_Detail_Ins.F_QTY, + RemeltTime = DateTime.Now + }; + SpecHelper.InsertRemeltDetail(target); + } + }); + } + else + { + tran.RollbackTran(); + result.resultCode = 17; + result.resultMsg = $"鐢熸垚浜哄伐鎷嗙洏鍏ュ簱浠诲姟澶辫触锛� + taskLog_New + taskLog1_Old; + LogHelper.Info(result.resultMsg); + return result; + } + } + else + { + tran.RollbackTran(); + result.resultCode = 18; + result.resultMsg = $"鐢熸垚浜哄伐鎷嗙洏鍏ュ簱浠诲姟澶辫触锛� + taskLog_New + taskLog1_Old; + LogHelper.Info(result.resultMsg); + return result; + } + } + } + catch (Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + + return result; + } + } +} diff --git a/api/ApiModel.cs b/api/ApiModel.cs new file mode 100644 index 0000000..6150bbc --- /dev/null +++ b/api/ApiModel.cs @@ -0,0 +1,448 @@ +锘縰sing System.Collections.Generic; + +namespace HH.WCS.Mobox3.DoubleCoin.api +{ + /// <summary> + /// 閫氱敤model + /// </summary> + public class ApiModel + { + #region hosttoagv 鐩稿叧 + /// <summary> + /// 杩斿洖缁檋osttoagv + /// </summary> + public class ReturnResult + { + public int ResultCode { get; set; } + public string ResultMsg { get; set; } + + } + /// <summary> + /// hosttoagv涓婃姤浠诲姟鐘舵� + /// </summary> + public class AgvTaskState + { + public int state { get; set; } + public string task_no { get; set; } + public string forklift_no { get; set; } + public string lock_no { get; set; } + public string ext_data { get; set; } + } + + + /// <summary> + /// hosttoagv涓婃姤杞﹁締鐘舵�锛堝弬鏁板湪hosttoagv鏈嶅姟閰嶇疆锛屽彲淇敼锛�+ /// </summary> + public class AgvDeviceStatus + { + public string forkliftNo { get; set; } + + public string errCode { get; set; } + + public string errCode2 { get; set; } + + public string faildCode { get; set; } + + public string xPos { get; set; } + + public string yPos { get; set; } + public string battery { get; set; } + public string detail { get; set; } + public string infoType { get; set; } + public string inMapRoute { get; set; } + public string CumInfo { get; set; } + } + /// <summary> + /// osttoagv涓婃姤鍏跺畠浜嬩欢淇℃伅 + /// </summary> + public class AgvEventInfo + { + public int Code { get; set; } + public string CarID { get; set; } + public string Param1 { get; set; } + public string Param2 { get; set; } + public string Param3 { get; set; } + + } + + #endregion + + #region mobox 鐩稿叧 + /// <summary> + /// mobox 鍙栨秷浠诲姟銆佹爣璁板畬鎴愪换鍔�+ /// </summary> + public class MoboxTaskBase + { + public string TaskNo { get; set; } + } + /// <summary> + /// mobox 鎺ュ彛杩斿洖 + /// </summary> + public class SimpleResult + { + public int resultCode { get; set; } + public string resultMsg { get; set; } + public List<object> result { get; set; } = new List<object>(); + } + + public class Result + { + public int resultCode { get; set; } + public string resultMsg { get; set; } + } + + /// <summary> + /// 缁戝畾 鍙傛暟 + /// </summary> + public class BindParme + { + /// <summary> + /// 鎵樼洏缂栫爜 + /// </summary> + public string CntrCode { get; set; } + /// <summary> + /// 鎵樼洏绫诲瀷 + /// </summary> + public string CntrType { get; set; } + /// <summary> + /// 璐т綅缂栫爜 + /// </summary> + public string LocCode { get; set; } + /// <summary> + /// 鐗╂枡缂栫爜 + /// </summary> + public string ItemCode { get; set; } + /// <summary> + /// 鐗╂枡鏁伴噺 + /// </summary> + public int ItemQuantity { get; set; } + } + + /// <summary> + /// 瑙g粦 鍙傛暟 + /// </summary> + public class UnBindParme + { + /// <summary> + /// 鎵樼洏缂栫爜 + /// </summary> + public string CntrCode { get; set; } + + } + + public class sendTask + { + + /// <summary> + /// 璁㈠崟鍚�+ /// </summary> + public string ts { get; set; } + } + + /// <summary> + /// 鏇存柊琛ヨ揣鐘舵�鍙傛暟 + /// </summary> + public class replenishmentParme + { + /// <summary> + /// Y寮�浜哄伐琛ヨ揣杩涘叆浜ら�绠″埗,N琛ㄧず浜哄伐琛ヨ揣瀹屾垚鍙互寮�惎鑷姩杞繍 + /// </summary> + public string stauts { get; set; } + } + + + public class orderStatusReportParme + { + /// <summary> + /// 璁㈠崟ID + /// </summary> + public int orderID { get; set; } + /// <summary> + /// 璁㈠崟鍚�+ /// </summary> + public string orderName { get; set; } + /// <summary> + /// 璁㈠崟鐘舵� + /// </summary> + public string orderStatus { get; set; } + /// <summary> + /// agv杞﹀彿鍒楄〃 + /// </summary> + public string agvIDList { get; set; } + /// <summary> + /// 浼樺厛绾�+ /// </summary> + public string priority { get; set; } + /// <summary> + /// 璁㈠崟褰撳墠鐨勭洰鐨勫湴 + /// </summary> + public string currentDes { get; set; } + + + /// <summary> + /// 褰撳墠鎸囦护 + /// </summary> + public string currentCmd { get; set; } + + /// <summary> + /// 閿欒鐮�+ /// </summary> + public int errorCode { get; set; } + + /// <summary> + /// 璁㈠崟鐨勬埅鑷虫椂闂�+ /// </summary> + public string deadLine { get; set; } + + /// <summary> + /// 璁㈠崟鐨勫垱寤烘椂闂�+ /// </summary> + public string createdTime { get; set; } + + /// <summary> + /// 棰濆淇℃伅1 + /// </summary> + public string extraInfo1 { get; set; } + + /// <summary> + /// 棰濆淇℃伅2 + /// </summary> + public string extraInfo2 { get; set; } + } + + /// <summary> + /// 鍒嗘嫞纭 + /// </summary> + public class SortingResultCheck + { + public string sortNo { get; set; } + public string cntrCode { get; set; } + public string itemCode { get; set; } + public float qty { get; set; } + } + public class CheckSortingWholeCntr + { + public string cntr { get; set; } + /// <summary> + /// 榛樿0锛�琛ㄧず鑷姩鐢熸垚鍒嗘嫞缁撴灉 + /// </summary> + public int autoSort { get; set; } + } + + /// <summary> + /// lua璋冪敤鎺ュ彛锛岀爜鐩樹俊鎭�+ /// </summary> + public class PalletSorting + { + public string cntr_code { get; set; } + public string item_code { get; set; } + public float qty { get; set; } + public string arrival_no { get; set; } + } + public class PalletSorting1 + { + public string cntr_code { get; set; } + public string bar_code { get; set; } + public string org { get; set; } + public float qty { get; set; } + } + + public class ShippingOrderCheck + { + /// <summary> + /// 澶氫釜鍙戣揣鍗曞彿 + /// </summary> + public string out_nos { get; set; } + } + public class SortingOrderCheck + { + + public string s_no { get; set; } + } + + public class ReturnResult1 + { + public int code { get; set; } + public string msg { get; set; } + + } + + /// <summary> + /// 瀹夊叏浜や簰 + /// </summary> + public class Interaction + { + public string station_name { get; set; } + public string apply_code { get; set; } + public int orderid { get; set; } + + } + /// <summary> + /// 杩斿洖缁橤Z + /// </summary> + public class GzResult + { + public int resultCode { get; set; } + public string msg { get; set; } + public int orderID { get; set; } + } + #endregion + } + + /// <summary> + /// 椤圭洰璁㈠埗model + /// </summary> + public class OtherModel + { + /// <summary> + /// mobox3鎺ュ彛鏇夸唬锛屽叆搴撳崟淇℃伅 + /// </summary> + public class Putaway_Order_In + { + public DataInfo Data { get; set; } + + public class DataInfo + { + /// <summary> + /// 鍏ュ簱鍗曞彿(鍞竴) + /// </summary> + public string arrival_no { get; set; } + /// <summary> + /// 鍗曟嵁绫诲瀷 + /// </summary> + public string op_type { get; set; } + public List<Detail> items { get; set; } + } + public class Detail + { + + public string item_code { get; set; } + /// <summary> + /// 淇濈暀4浣嶅皬鏁�+ /// </summary> + public float qty { get; set; } + public string batch_no { get; set; } + } + } + + public class OutboundOrder + { + public DataInfo1 Data { get; set; } + public class DataInfo1 + { + /// <summary> + /// 鍑哄簱鍗曞彿(鍞竴) + /// </summary> + public string out_no { get; set; } + /// <summary> + /// 鍗曟嵁绫诲瀷 + /// </summary> + public string op_type { get; set; } + /// <summary> + /// 鐢熶骇鍑哄簱鐨勯渶瑕佹寚瀹氱嚎杈瑰簱鍖�+ /// </summary> + public string line_area { get; set; } + public List<Detail1> items { get; set; } + } + public class Detail1 + { + + public string item_code { get; set; } + /// <summary> + /// 淇濈暀4浣嶅皬鏁�+ /// </summary> + public float qty { get; set; } + public string batch_no { get; set; } + } + } + public class ApiBaseModel + { + public string Name { get; set; } + public string Source { get; set; } + } + + + /// <summary> + /// DoubleCoin鐢熶骇宸ュ崟鐨凙PI Model + /// </summary> + public class InstockInfo + { + public string start { get; set; } + public string cntr { get; set; } + } + + /// <summary> + /// 瀵规帴鏃剁敓浜у伐鍗曠殑Model + /// </summary> + public class WorkOrderInfo + { + public string S_WORK_NO { get; set; }//宸ュ崟鍙凤紝涓婚敭 + public string S_ITEM_CODE { get; set; }//鐗╂枡缂栫爜 + public string S_BATCH_NO { get; set; }//鎵规鍙�+ public string S_ITEM_SPEC { get; set; }//瑙勬牸 + public string S_LINE_NO { get; set; }//浜х嚎锛屼笉鑳戒负null + + } + + /// <summary> + /// 鎺ユ敹PDA缁戝畾淇℃伅鐨凪odel + /// </summary> + public class BindInfo + { + public string RFID { get; set; }//RFID锛屽閿紝鏄鍣ㄦ槸鎵樼洏 + + public int CarNum { get; set; }//鐢熶骇杞︽暟 + } + + public class FullOutWarehouseInfo + { + public string EndLoc { get; set; }//缁堢偣 + public string Spe { get; set; }//瑙勬牸 + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class EmptyInStackAreaInfo + { + public string startLoc { get; set; }//璧风偣 + public string cntID { get; set; }//瀹瑰櫒ID + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class InWarehouseInfo + { + public string startLoc { get; set; }//璧风偣 + + public string cntID { get; set; }//瀹瑰櫒ID + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class SplitOutWarehouseInfo + { + public string cntID { get; set; }//瀹瑰櫒鍙�+ public string endLoc { get; set; }//缁堢偣 + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class ResultInWarehouseInfo + { + public string old_CntId { get; set; }//鏃у鍣↖D锛岃鎷嗙殑 + public string old_StartLoc { get; set; }//鏃у鍣ㄧ殑璧风偣 + public int old_IsOK { get; set; }//鏃у鍣↖D锛屾棫瀹瑰櫒鐨勮揣鍝佺殑0鍚堟牸1涓嶅悎鏍�+ public string new_CntIds { get; set; }//鎷嗗悗鐨勬柊瀹瑰櫒ID + public string new_StartLoc { get; set; }//鏂板鍣↖D璧风偣 + public int new_IsOK { get; set; }//鏂板鍣↖D鐨勮揣鍝佺殑0鍚堟牸1涓嶅悎鏍硷紵 + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class UpCgDetailModel + { + public string cntID { get; set; }//瀹瑰櫒ID + public int state { get; set; }//鐗╂枡鐘舵� + public string stateInfo { get; set; }//鐗╂枡鐘舵�淇℃伅 + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + } +} diff --git a/api/DebugController.cs b/api/DebugController.cs new file mode 100644 index 0000000..3fe256c --- /dev/null +++ b/api/DebugController.cs @@ -0,0 +1,111 @@ +锘�+using HH.WCS.Mobox3.DoubleCoin.core; +using HH.WCS.Mobox3.DoubleCoin.device; +using HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.models; +using HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Web.Http; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiHelper; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; +using static HH.WCS.Mobox3.DoubleCoin.api.OtherModel; + +namespace HH.WCS.Mobox3.DoubleCoin.api +{ + /// <summary> + /// 娴嬭瘯鐢紝濡傛灉椤圭洰涓鍜岃澶囧鎺ワ紝鍓嶆湡璁惧鏃犳硶娴嬭瘯锛岀敤鎺ュ彛妯℃嫙 + /// </summary> + [RoutePrefix("api")] + public class DebugController : System.Web.Http.ApiController + { + /// <summary> + /// AGV鐘舵�涓�敭鍥炴姤134562 + /// </summary> + /// <param name="model">瀹瑰櫒鍙�/param> + /// <returns></returns> + [HttpPost] + [Route("AGVSeriesReports")] + public ReturnResults AGVSeriesReports(UpdateTaskState model) + { + var agvTaskState = new AgvTaskState() + { + task_no = model.TaskID, + forklift_no = model.ForkliftNo, + state = 1 + }; + ReturnResults returnResult = new ReturnResults(); + returnResult.resulat = new List<ReturnResult>(); + + var temp1 = WCSCore.OperateAgvTaskStatus(agvTaskState); + returnResult.resulat.Add(temp1); + + agvTaskState.state = 3; + var temp3 = WCSCore.OperateAgvTaskStatus(agvTaskState); + returnResult.resulat.Add(temp3); + + agvTaskState.state = 4; + var temp4 = WCSCore.OperateAgvTaskStatus(agvTaskState); + returnResult.resulat.Add(temp4); + + agvTaskState.state = 5; + var temp5 = WCSCore.OperateAgvTaskStatus(agvTaskState); + returnResult.resulat.Add(temp5); + + agvTaskState.state = 6; + var temp6 = WCSCore.OperateAgvTaskStatus(agvTaskState); + returnResult.resulat.Add(temp6); + + agvTaskState.state = 2; + var temp2 = WCSCore.OperateAgvTaskStatus(agvTaskState); + returnResult.resulat.Add(temp2); + + return returnResult; + } + /// <summary> + /// 鍒濆鍖栨暟鎹簱 + /// </summary> + /// <returns></returns> + [HttpPost] + [Route("BuildDB")] + public string BuildDB() + { + + bool res = false; + try + { + + + var db = new SqlHelper<object>().GetInstance(); + //db.CodeFirst.InitTables<WCSTask>(); //鎵�湁搴撻兘鏀寔 + //db.CodeFirst.InitTables<Zone>(); + //db.CodeFirst.InitTables<Area>(); + //db.CodeFirst.InitTables<Location>(); + //db.CodeFirst.InitTables<LocCntrRel>(); + //db.CodeFirst.InitTables<Container>(); + //db.CodeFirst.InitTables<TN_CG_Detail>(); + //db.CodeFirst.InitTables<TN_WorkOrder>(); + //db.CodeFirst.InitTables<TN_CAR_IN>(); + //db.CodeFirst.InitTables<OI_SYS_MAXID>(); + //db.CodeFirst.InitTables<TN_Task_Action>(); + } + catch (Exception ex) + { + + } + return res ? "鎴愬姛" : "澶辫触"; + } + } + + public class UpdateTaskState + { + public string TaskID { set; get; }//浠诲姟ID + public string ForkliftNo { set; get; } + } + + public class ReturnResults + { + public List<ReturnResult> resulat { set; get; } + } +} diff --git a/api/MoboxController.cs b/api/MoboxController.cs new file mode 100644 index 0000000..8bcbe5c --- /dev/null +++ b/api/MoboxController.cs @@ -0,0 +1,214 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.process; +using HH.WCS.Mobox3.DoubleCoin.util; +using HH.WCS.Mobox3.DoubleCoin.wms; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Web.Http; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; +using static HH.WCS.Mobox3.DoubleCoin.api.OtherModel; +using static HH.WCS.Mobox3.DoubleCoin.dispatch.NDC; + +namespace HH.WCS.Mobox3.DoubleCoin.api +{ + /// <summary> + /// mobox3璋冪敤锛岃剼鏈腑璋冪敤 + /// </summary> + [RoutePrefix("api")] + public class MoboxController : System.Web.Http.ApiController { + + /// <summary> + /// 鎺ユ敹宸ュ崟淇℃伅 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + //[HttpPost] + //[Route("ReceiveWorkOrder")] + //public SimpleResult ReceiveWorkOrder(WorkOrderInfo model) + //{ + // return ApiHelper.ReceiveWorkOrder(model); + //} + + /// <summary> + /// 缁戝畾瀹瑰櫒鐢熶骇杞︽暟淇℃伅 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + //[HttpPost] + //[Route("CarNumBind")] + //public SimpleResult CarNumBind(BindInfo model) + //{ + // return ApiHelper.CarNumBind(model); + //} + + /// <summary> + /// 鏇存柊鐗╂枡鏄庣粏鐨勭姸鎬侊紝0鍚堟牸1寰呮2涓嶅悎鏍硷紝涓嬬嚎鍗冲緟妫�+ /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("UpCgDetailModel")] + public SimpleResult UpCgDetailModel(UpCgDetailModel model) + { + return ApiHelper.UpCgDetailModel(model); + } + + /// <summary> + /// 婊℃墭鍑哄簱涓婄嚎 + /// </summary> + /// <param name="model"></param> + /// <returns>s</returns> + [HttpPost] + [Route("FullOutWarehouse")] + public SimpleResult FullOutWarehouse(FullOutWarehouseInfo model) + { + return ApiHelper.FullOutWarehouse(model); + } + + /// <summary> + /// 绌烘墭涓嬬嚎鍫嗗彔锛堝彧缁戝畾璐т綅瀹瑰櫒涓嶅垱寤轰换鍔★級 + /// </summary> + /// <param name="model"></param> + /// <returns>s</returns> + [HttpPost] + [Route("EmptyInStackArea")] + public SimpleResult EmptyInStackArea(EmptyInStackAreaInfo model) + { + return ApiHelper.EmptyInStackArea(model); + } + + /// <summary> + /// 浣欐枡涓嬬嚎鍏ュ簱 + /// </summary> + /// <param name="model"></param> + /// <returns>s</returns> + [HttpPost] + [Route("SurplusInWarehouse")] + public SimpleResult SurplusInWarehouse(InWarehouseInfo model) + { + return ApiHelper.SurplusInWarehouse(model); + } + + /// <summary> + /// 浜哄伐鎷嗙洏鍑哄簱 + /// </summary> + /// <param name="model"></param> + /// <returns>s</returns> + //[HttpPost] + //[Route("SplitOutWarehouse")] + //public SimpleResult SplitOutWarehouse(SplitOutWarehouseInfo model) + //{ + // return ApiHelper.SplitOutWarehouse(model); + //} + + /// <summary> + /// 浜哄伐鎷嗙洏鍏ュ簱 + /// </summary> + /// <param name="model"></param> + /// <returns>s</returns> + [HttpPost] + [Route("ResultInWarehouse")] + public SimpleResult ResultInWarehouse(ResultInWarehouseInfo model) + { + return ApiHelper.ResultInWarehouse(model); + } + + /// <summary> + /// 绾胯竟瑙g粦鎴愮┖鎵�+ /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("EmptyUnBind")] + public SimpleResult EmptyUnBind(EmptyUnBindInfo model) + { + return LocationHelper.EmptyUnBind(model); + } + + /// <summary> + /// 浜哄伐鎵嬪姩PDA瑙g粦锛氬垹闄よ揣浣�瀹瑰櫒/璐у搧涓夋柟淇℃伅锛�=瑙g粦璐т綅涓庡鍣紝2=瑙g粦瀹瑰櫒涓庤揣鍝�+ /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("PdaUnBind")] + public SimpleResult PdaUnBind(PdaUnBindInfo model) + { + return LocationHelper.PdaUnBind(model); + } + + /// <summary> + /// 浜哄伐鎵嬪姩PDA鍙栨秷浠诲姟锛�=鍙戠粰AGV鍙栨秷浠诲姟 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + //[HttpPost] + //[Route("PDACancleTask")] + //public SimpleResult PDACancleTask(CancleTaskInfo model) + //{ + // return WMSHelper.PDACancleTask(model); + //} + + /// <summary> + /// PDA婊℃墭涓嬬嚎鍏ュ簱鍛煎彨 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("PDAFullInArea")] + public SimpleResult PDAFullInArea(PDAFullInAreaInfo model) + { + return ApiHelper.PDAFullInArea(model); + } + + /// <summary> + /// PDA婊℃墭鍑哄簱鎶芥 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + //[HttpPost] + //[Route("PDAFullCheckOut")] + //public SimpleResult PDAFullCheckOut(PDAFullCheckInfo model) + //{ + // return ApiHelper.PDAFullCheckOut(model); + //} + + /// <summary> + /// PDA婊℃墭鎶芥鍒ゆ柇 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("PDAFullCheckIn")] + public SimpleResult PDAFullCheckIn(PDAFullCheckInfo model) + { + return ApiHelper.PDAFullCheckIn(model); + } + + /// <summary> + /// 鏄剧ず婊℃墭缂撳瓨搴撳綋鍓嶈鏍肩殑鎵樼洏鏁伴噺 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("ShowCntCountBySpe")] + public string ShowCntCountBySpe(ShowCntCountBySpeInfo model) + { + return ApiHelper.ShowCntCountBySpe(model); + } + + /// <summary> + /// 浜哄伐娆″搧鍥炵倝 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + [HttpPost] + [Route("PDAReturnReset")] + public SimpleResult PDAReturnReset(PDAReturnResetInfo model) + { + return ApiHelper.PDAReturnReset(model); + } + } +} diff --git a/api/WmsController.cs b/api/WmsController.cs new file mode 100644 index 0000000..dd9fed0 --- /dev/null +++ b/api/WmsController.cs @@ -0,0 +1,20 @@ +锘�+using HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Web.Http; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiHelper; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; +using static HH.WCS.Mobox3.DoubleCoin.api.OtherModel; + +namespace HH.WCS.Mobox3.DoubleCoin.api +{ + /// <summary> + /// 绗笁鏂硅皟鐢ㄧ殑鎺ュ彛 + /// </summary> + [RoutePrefix("api")] + public class WmsController : System.Web.Http.ApiController + { + + } +} diff --git a/config/config.json b/config/config.json new file mode 100644 index 0000000..b8e6c1e --- /dev/null +++ b/config/config.json @@ -0,0 +1,46 @@ +{ + "WebApiUrl": "http://127.0.0.1:8901/", + "NDCApiUrl": "http://127.0.0.1:5201/api/order/", + "SqlServer": "Data Source=127.0.0.1;Initial Catalog=DoubleCoinTest;User ID=sa;Password=123456;", + "TCPServerIP": "127.0.0.1", + "TCPServerPort": 8085, + "Areas": [ "SQKQ1", "SQKQ2", "SQKQ3", "SQKQ4", "SQKQ5", "SQKQ6", "SQKQ7", "SQKQ8", "SQKQ9", "SQKQ10", "SQKQ11", "SQKQ12", "SQKQ13" ], + "S7TestMoni": true, + "IsOpenScanCode": true, + "ProductionLine": [ + { + "ProductionLine_IP": "127.0.0.1", + "ProductionLine_Name": "1", + "ProductionLine_Rack": 0, + "ProductionLine_Slot": 1, + "PointIn": "SQKQ1-1", + "PointOut": "SQKQ1-2" + } + ], + "AgvScanDevice": [ + { + "AgvCode": "string", + "ScanAddress": "127.0.0.1" + }, + { + "AgvCode": "string01", + "ScanAddress": "127.0.0.2" + } + ], + "SafeDoorDevices": [ + { + "DeviceCode": "1", + "DeviceName": "1号卷帘门", + "IPAddress": "127.0.0.1" + } + ], + "WeightDevices": [ + { + "WeightDevice_IP": "127.0.0.2", + "WeightDevice_Name": "1", + "WeightDevice_Rack": 0, + "WeightDevice_Slot": 1, + "Point": "SQKQ7-1" + } + ] +} \ No newline at end of file diff --git a/config/configDesc.txt b/config/configDesc.txt new file mode 100644 index 0000000..080f22a --- /dev/null +++ b/config/configDesc.txt @@ -0,0 +1,60 @@ +锘�/閰嶇疆璇存槑锛坖son閰嶇疆閲岄潰涓嶈兘鍔犳敞閲婏紝鍗曠嫭鍐欎釜璇存槑鏂囦欢锛�+"WebApiUrl": "http://127.0.0.1:8901",//鑷韩鐨刉ebApi鍦板潃锛岃鍏朵粬绋嬪簭Post璋冪敤 +"SqlServer": "Data Source=192.168.1.144;Initial Catalog=SQMobox;User ID=hhuser;Password=Am123123",//杩炴帴SQL Server鏁版嵁搴撶殑杩炴帴瀛楃涓�+"HostToAgvServerUrl": "http://127.0.0.1:9988/HostToAGV.cgi",//杩炴帴AGV绠$悊绯荤粺鐨勫湴鍧�+"TCPServerIP": "127.0.0.1",//Socket鏈嶅姟绔湴鍧�紝鐢ㄤ簬杩炴帴AGV璇诲崱鍣ㄥ苟閫氳 +"TCPServerPort": 8085,//Socket鏈嶅姟绔鍙o紝鐢ㄤ簬杩炴帴AGV璇诲崱鍣ㄥ苟閫氳 +"Areas": [ "SQKQ1", "SQKQ2", "SQKQ3", "SQKQ4", "SQKQ5" , "SQKQ6", "SQKQ7", "SQKQ8", "SQKQ9", "SQKQ10" , "SQKQ11", "SQKQ12" ], +// 鍘熸潗鏂欎骇绾垮簱鍖篠QKQ1鈥斺�銆嬫弧鎵樼紦瀛樺簱鍖篠QKQ2鈥斺�銆嬪姞宸ョ嚎绾胯竟鍖篠QKQ3鈥斺�銆嬬┖鎵樺爢鍙犲尯SQKQ4鈥斺�銆嬬┖鎵樼紦瀛樺簱鍖篠QKQ5鈥斺�銆�+//浜哄伐鎷嗙洏鍖篠QKQ6鈥斺�銆嬩汉宸ョ┖鎵樺尯SQKQ7鈥斺�銆嬩汉宸ユ娊妫�尯SQKQ8鈥斺�銆嬫媶鐩樹笉鍚堟牸鍖篠QKQ9鈥斺�銆嬬О閲嶅尯SQKQ10 +//鈥斺�銆嬩綑鏂欒捣鐐瑰尯SQKQ11鈥斺�銆嬫鍝佸洖鐐夊尯SQKQ12 鈥斺�銆嬭繃鏈熸殏瀛樺尯SQKQ13 + +"S7TestMoni": true,//濡傛灉涓簍rue锛岃烦杩嘢7閫氳娴嬭瘯锛屽彧鑳戒娇鐢≒DA +"IsOpenScanCode": true,//濡傛灉涓簍rue锛屽紑鍚鍗″櫒鎵爜鍔熻兘锛屽鏋滀负false锛屼笉寮�惎 +"ProductionLine": [ + { + "ProductionLine_IP": "127.0.0.2", + "ProductionLine_Name": "1", + "ProductionLine_Rack": 0, + "ProductionLine_Slot": 1, + "PointIn": "SQKQ1-1", + "PointOut": "SQKQ1-2" + } +],//鍘熸潗鏂欎骇绾垮簱鍖虹殑鍚勪釜浜х嚎淇℃伅琛紝鐢ㄤ簬S7閫氳鑾峰彇涓婄┖鎵樹笅婊℃墭淇″彿锛屾湁鍥哄畾鐨勪竴鍑轰竴杩涜揣浣嶅彛 + +"AgvScanDevice": [ + { + "AgvCode": "1", + "AgvAddress": "127.0.0.1" + } +],//鎵�湁鐨凙GV璇诲崱鍣ㄥ鎴风閰嶇疆淇℃伅锛岄渶瑕佹彁鍓嶅綍鍏ュ瓧鍏镐腑涓庝箣閫氳 + +"SafeDoorDevices": [ + { + "DeviceCode": "1",//鍗峰笜闂ㄧ紪鍙�+ "DeviceName": "1鍙峰嵎甯橀棬",//鍗峰笜闂ㄥ悕绉�+ "IPAddress": "127.0.0.1",//鍗峰笜闂ㄩ�璁湴鍧�+ "Port": 502//鍗峰笜闂ㄩ�璁鍙�+ } + ] +},//鎵�湁瀹夊叏闂ㄤ氦浜掕澶囦俊鎭〃 + +"WeightDevices": [ + { + "WeightDevice_IP": "127.0.0.1", + "WeightDevice_Name": "1", + "WeightDevice_Rack": 0, + "WeightDevice_Slot": 1, + "Point": "SQKQ3-1" + } + ],//鎵�湁绉伴噸璁惧淇℃伅琛紙涓嶅寘鎷師鏉愭枡浜х嚎鐨勭О閲嶈澶囷紝鍙敤浜庝綑鏂欏洖搴撳拰鎷嗙洏鍥炲簱鐨勭О閲嶇幆鑺傦級 + "SpeAndTimes": [ + { + "Spe": "1", + "Minute": 100 //鍗曚綅锛氬垎閽�+ } + ]//涓嶅悓鐨勮鏍煎搴斾笉鍚岀殑闈欑疆鏃堕棿 + + + + diff --git a/core/Monitor.cs b/core/Monitor.cs new file mode 100644 index 0000000..1175125 --- /dev/null +++ b/core/Monitor.cs @@ -0,0 +1,792 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.device; +using HH.WCS.Mobox3.DoubleCoin.models; +using HH.WCS.Mobox3.DoubleCoin.util; +using HH.WCS.Mobox3.DoubleCoin.wms; +using Newtonsoft.Json; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.core +{ + /// <summary> + /// 瀹氭椂杞浠诲姟 + /// </summary> + internal class Monitor + { + + /// <summary> + /// 婊℃墭涓嬬嚎鍏ュ簱锛岀┖鎵樺嚭搴撲笂绾�+ /// </summary> + internal static void CheckS7Devices() + { + + if (S7Helper.ip_Plc.Count <= 0 || Settings.ProductionLines.Count <= 0) + { + LogHelper.Info($"娌℃湁閰嶇疆S7璁惧淇℃伅锛孋heckDevices璺宠繃", "PLC"); + return; + } + + S7Helper.RestLink(); + + foreach (var plcD in Settings.ProductionLines)//閬嶅巻姣忎釜浜х嚎 + { + + Task task = Task.Run(() => + { + if (Settings.S7TestMoni) + { + LogHelper.Info($"閰嶇疆鏂囦欢涓璖7TestMoni涓篢rue锛屽凡璺宠繃鍘熸潗鏂欑敓浜х嚎S7閫氳鐨勮嚜鍔ㄤ换鍔$敓鎴愶紝濡傛灉鐢熶骇绾垮彲浠ヤ娇鐢紝S7TestMoni鏀逛负false"); + return; + } + + CheckDeciveModel result = new CheckDeciveModel(); + var db = new SqlHelper<object>().GetInstance(); + byte[] readBytes1; + try + { + + if (S7Helper.WriteBytes(plcD.ProductionLine_IP, 10, 4, new byte[] { 1 })) + { + LogHelper.Info($"浜х嚎{result.LineIP}鍐欏叆DB10鐨勫亸绉�涓�锛孭2_Turn on the signal = 1锛屾垚鍔�); + } + else + { + LogHelper.Info($"浜х嚎{result.LineIP}鍐欏叆DB10鐨勫亸绉�涓�锛孭2_Turn on the signal = 1锛屽け璐�); + } + + Task.Delay(500); // 寤惰繜 0.5 绉掞紝璁╁畠绉伴噸 + + //閫氳繃S7鍗忚鑾峰彇涓嬩綅鏈轰俊鍙�+ result.LineIP = plcD.ProductionLine_IP; + readBytes1 = S7Helper.ReadBytes(plcD.ProductionLine_IP, 20, 0, 13); + if (readBytes1 == null) + { + LogHelper.Info($"璇诲彇S7_PLC淇℃伅涓虹┖" + plcD.ProductionLine_IP, "PLC"); + return; + } + result.Heart = ((readBytes1[0]) << 8) + readBytes1[1]; + + byte[] rfid = new byte[4] { readBytes1[2], readBytes1[3], readBytes1[4], readBytes1[5] }; + + string rfids16 = BitConverter.ToString(rfid); + string rfids = (((readBytes1[2]) << 24) + (readBytes1[3] << 16) + (readBytes1[4] << 8) + readBytes1[5]).ToString(); + LogHelper.Info($"浜х嚎瀹瑰櫒鍙凤細{rfids}锛屽叾16杩涘埗褰㈠紡锛歿rfids16}"); + result.RfidData = rfids; + + result.AgvAllow = (((readBytes1[6]) << 8) + readBytes1[7]); + result.TaskProperties = readBytes1[8]; + result.Ready = readBytes1[9]; + result.CargoStatus = readBytes1[10]; + result.StationStatus = readBytes1[11]; + result.DestinationRequests = readBytes1[12]; + + result.BarcodeCode = S7Helper.ReadString(plcD.ProductionLine_IP, 20, 14, 10); + + var readBytes2 = S7Helper.ReadBytes(plcD.ProductionLine_IP, 20, 26, 2); + + result.Weight = ((readBytes2[0]) << 8) + readBytes2[1]; + + LogHelper.Info($"PLC瑙f瀽鍚庤缁嗕俊鎭紝{JsonConvert.SerializeObject(result)}"); + } + catch (Exception ex) + { + LogHelper.Info($"璇诲彇S7_PLC淇℃伅寮傚父:{ex.Message}" + plcD.ProductionLine_IP, "Error"); + return; + } + + + //鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟 + if (result.AgvAllow == 21 && result.Ready == 1 && result.DestinationRequests == 1) + { + LogHelper.Info($"瑙﹀彂寮�鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟"); + + //璇ヤ骇绾跨殑婊℃墭涓嬬嚎浣嶇疆锛岃捣鐐�+ var startPoint = Settings.ProductionLines.FirstOrDefault(a => a.ProductionLine_IP == result.LineIP); + if (startPoint != null)//璧风偣瀛樺湪 + { + var woInfo = db.Queryable<TN_WorkOrder>().Where(a => a.S_LINE_NO == startPoint.ProductionLine_Name && a.S_B_STATE == "寮�惎").OrderBy(b => b.T_CREATE, OrderByType.Desc).First(); + + if (woInfo != null)//褰撳墠浜х嚎涓嶅瓨鍦ㄥ紑鍚殑鏈�柊鐨勫伐鍗�+ { + var startLoc = db.Queryable<TN_Location>().First(a => a.S_LOCK_STATE == "鏃� && a.N_LOCK_STATE == 0 && a.S_CODE == startPoint.PointOut && a.C_ENABLE == "Y"); + if (startLoc != null)//璇ヤ骇绾跨殑璧风偣娌¢攣浣�+ { + var modelCI = db.Queryable<TN_CAR_IN>().First(i => i.S_CNTR_CODE == result.RfidData && i.S_B_STATE == "0");//鏌ヨ鏄惁鏈夎繖涓搴旂殑涓旂姸鎬佹甯哥殑瀹瑰櫒杞﹀彿瀛愯〃 + if (modelCI != null)//瀹瑰櫒杞﹀彿瀛愯〃瀛樺湪 + { + var cgInfo = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == result.RfidData); + + if (cgInfo != null)//鏈夋畫鐣欑殑瀹瑰櫒璐у搧鏄庣粏鍏崇郴琛ㄤ俊鎭�+ { + LogHelper.Info($"瀹瑰櫒{result.RfidData}宸茬粦瀹氳揣鍝亄cgInfo.S_ITEM_CODE}锛屽鏋滄槸鍏朵粬搴撳尯鐨勫鍣紝鎯宠浣跨敤锛屽厛瑙g粦"); + } + else + { + var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == result.RfidData); + if (locCntrRel != null)//褰撳墠瀹瑰櫒鏄惁缁戝畾浜嗚揣浣嶏紝缁戝畾浜嗗氨鍒犻櫎鏃х殑鍐嶆柊澧�+ { + LogHelper.Info($"瀹瑰櫒{result.RfidData}宸茬粦瀹氳揣浣峽locCntrRel.S_LOC_CODE}锛屽鏋滄槸鍏朵粬搴撳尯鐨勫鍣紝鎯宠浣跨敤锛屽厛瑙g粦"); + } + else + { + var endLoc = db.Queryable<TN_Location>(). + Where(c => c.S_AREA_CODE == Settings.Areas[1] && c.S_LOCK_STATE == "鏃� && c.N_LOCK_STATE == 0 && c.N_CURRENT_NUM == 0 && c.C_ENABLE == "Y"). + OrderBy(o => o.T_MODIFY, OrderByType.Asc).First();//鏌ヨ鍚堥�鐨勭粓鐐硅揣浣嶏紝鐩存帴鍒ゆ柇褰撳墠鏁伴噺涓�鍗冲彲 + + if (endLoc != null) + { + //鏂板璐т綅瀹瑰櫒鍏崇郴琛�+ locCntrRel = new TN_Loc_Container() + { + S_LOC_CODE = startPoint.PointOut, + S_CNTR_CODE = result.RfidData, + }; + + TN_CG_Detail tN_CG_Detail = new TN_CG_Detail()//鏂板瀹瑰櫒璐у搧鏄庣粏琛�+ { + S_CNTR_CODE = result.RfidData, + S_ITEM_CODE = woInfo.S_ITEM_CODE, + S_BATCH_NO = woInfo.S_BATCH_CODE, + S_ITEM_SPEC = woInfo.S_ITEM_SPEC, + S_SPE = woInfo.S_ITEM_SPEC, + S_CAR_CODE = modelCI.S_CAR_CODE, + N_ITEM_STATE = 1, + S_ITEM_STATE = "寰呮", + F_QTY = result.Weight,//杩欓噷鐨勯噸閲忚褰撴垚鏁伴噺鏉ヤ娇鐢�+ }; + + var task1 = new TN_Task() + { + S_CODE = WCSHelper.GenerateTaskNo(), + S_START_AREA = startLoc.S_AREA_CODE, + S_END_AREA = endLoc.S_AREA_CODE, + S_START_LOC = startLoc.S_CODE, + S_END_LOC = endLoc.S_CODE, + S_TYPE = "PLC婊℃墭涓嬬嚎鍏ュ簱", + N_B_STATE = 0, + S_B_STATE = "绛夊緟", + S_CNTR_CODE = result.RfidData, + S_SPEC = woInfo.S_ITEM_SPEC, + }; + + startLoc.N_LOCK_STATE = 2; + startLoc.S_LOCK_STATE = "鍑哄簱閿�; + startLoc.N_CURRENT_NUM = 1; + startLoc.T_MODIFY = System.DateTime.Now; + + endLoc.N_LOCK_STATE = 1; + endLoc.S_LOCK_STATE = "鍏ュ簱閿�; + startLoc.T_MODIFY = System.DateTime.Now; + + using (var tran = db.Ado.UseTran()) + { + if (db.Insertable<TN_Task>(task1).ExecuteCommand() > 0 && + db.Updateable<TN_Location>(startLoc).ExecuteCommand() > 0 && + db.Updateable<TN_Location>(endLoc).ExecuteCommand() > 0 && + db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() > 0 && + db.Insertable<TN_CG_Detail>(tN_CG_Detail).ExecuteCommand() > 0)//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + tran.CommitTran(); + LogHelper.Info($"鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟鎴愬姛锛屽鍣細{modelCI.S_CNTR_CODE}锛岃捣鐐癸細{startPoint.PointOut}锛岀粓鐐癸細{endLoc.S_CODE}"); + + Task task98 = Task.Run(() => + { + var target = new TN_EquipProDetail() + { + S_ID = tN_CG_Detail.S_ID, + TaskType = "PLC婊℃墭涓嬬嚎鍏ュ簱", + RFID = result.RfidData, + Spec = woInfo.S_ITEM_SPEC, + CarCode = modelCI.S_CAR_CODE, + Weight = result.Weight, + ItemState = "寰呮", + ItemCode = woInfo.S_ITEM_CODE, + LoginName = woInfo.S_LINE_NO, + Shift = "None", + StartLoc = startLoc.S_CODE, + }; + SpecHelper.InsertEquipProDetail(target); + }); + + Task task27 = Task.Run(() => + { + var target = new TN_InventoryM() + { + S_ID = tN_CG_Detail.S_ID, + RFID = result.RfidData, + Spec = woInfo.S_ITEM_SPEC, + Weight = result.Weight, + ItemState = "寰呮", + ItemCode = woInfo.S_ITEM_CODE, + LoginName = woInfo.S_LINE_NO, + Shift = "None", + }; + SpecHelper.InsertInventoryM(target); + }); + } + else + { + tran.RollbackTran(); + LogHelper.Info($"鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟澶辫触锛屽鍣細{modelCI.S_CNTR_CODE}锛岃捣鐐癸細{startPoint.PointOut}锛岀粓鐐癸細{endLoc.S_CODE}"); + } + } + } + else + { + LogHelper.Info($"鏈壘鍒板悎閫傜殑缁堢偣锛屽鍣細{modelCI.S_CNTR_CODE}锛岄渶瑕佹弧瓒筹細鏈夋湭閿佸畾鐨勶紝褰撳墠鏁伴噺涓�鐨勶紝灞炰簬{Settings.Areas[1]}鐨勮揣浣�); + } + } + } + } + else + { + LogHelper.Info($"鏈壘鍒板搴旂殑瀹瑰櫒杞﹀彿瀛愯〃淇℃伅锛屽鍣▄result.RfidData}"); + } + } + else + { + LogHelper.Info($"姝よ捣鐐逛綅缃細{startPoint.PointOut}宸查攣浣�); + } + } + else + { + LogHelper.Info($"褰撳墠浜х嚎{startPoint.ProductionLine_Name}浣嶇疆{startPoint.PointOut}娌℃湁寮�惎鐨勫伐鍗�); + } + } + else + { + LogHelper.Info($"鏈湪閰嶇疆鏂囦欢閲屾壘鍒拌浜х嚎{result.LineIP}璧风偣PointOut"); + } + } + else + { + LogHelper.Info($"鐢熸垚婊℃墭涓嬬嚎鍏ュ簱浠诲姟澶辫触锛屼笉婊¤冻result.AgvAllow == 21 && result.Ready == 1 && result.DestinationRequests == 1"); + } + + + if (result.AgvAllow == 11 && result.Ready == 1) + { + LogHelper.Info($"瑙﹀彂寮�鐢熸垚绌烘墭鍑哄簱涓婄嚎浠诲姟"); + + var endPoint = Settings.ProductionLines.FirstOrDefault(a => a.ProductionLine_IP == result.LineIP); + if (endPoint == null) + { + LogHelper.Info($"鏈壘鍒伴厤缃俊鎭紝浜х嚎IP锛歿result.LineIP}"); + return; + } + + var endLoc = db.Queryable<TN_Location>(). + First(a => a.S_CODE == endPoint.PointIn && a.S_LOCK_STATE == "鏃� && a.N_LOCK_STATE == 0 && a.C_ENABLE == "Y"); + + if (endLoc == null) + { + LogHelper.Info($"姝や綅缃細{endPoint.PointIn}宸查攣浣忔垨鏈惎鐢�); + return; + } + + if (endLoc.N_CURRENT_NUM > 0) + { + LocationHelper.ErrorLocCntReset(new ErrorLocCntResetInfo() { locID = endPoint.PointIn, reqCode = 1 }); + LogHelper.Info($"缁堢偣璐т綅{endPoint.PointIn}瀹瑰櫒鏁伴噺涓嶄负0锛屽凡閲嶇疆璇ヨ揣浣�); + } + + var startLoc = db.Queryable<TN_Location>(). + Where(o => o.S_AREA_CODE == Settings.Areas[4] && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.C_ENABLE == "Y" && o.N_CURRENT_NUM > 0). + OrderBy(o => o.N_CURRENT_NUM, OrderByType.Desc). + First(); + + if (startLoc == null) + { + LogHelper.Info($"鏈湪{Settings.Areas[4]}鎵惧埌鍚堥�鐨勮捣鐐癸紝闇�婊¤冻锛氳揣浣嶅綋鍓嶆暟閲忓ぇ浜�锛岃揣浣嶆湭閿佸畾"); + return; + } + + var cntrList = db.Queryable<TN_Loc_Container>().Where(a => a.S_LOC_CODE == startLoc.S_CODE).ToList(); + if (cntrList.Count == 0) + { + LogHelper.Info($"璧风偣璐т綅{startLoc.S_CODE}鏈壘鍒拌揣浣嶅鍣ㄥ叧绯昏〃淇℃伅"); + return; + } + + string cntrString = ""; + for (int i = 0; i < cntrList.Count; i++) + { + if (i == cntrList.Count - 1)//鏈�悗涓�釜瀛楃涓茶繛鎺ヤ笉鍔犻�鍙�+ { + cntrString += cntrList[i].S_CNTR_CODE; + } + else + { + cntrString += cntrList[i].S_CNTR_CODE + ","; + } + } + + if (WCSHelper.CreateTask(startLoc.S_CODE, endPoint.PointIn, "绌烘墭鍑哄簱鍏ョ嚎", 3, cntrString))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ + LogHelper.Info($"鐢熸垚绌烘墭鍑哄簱涓婄嚎浠诲姟鎴愬姛锛屽鍣細{cntrString}锛岃捣鐐癸細{startLoc.S_CODE}"); + } + else + { + LogHelper.Info($"鐢熸垚绌烘墭鍑哄簱涓婄嚎浠诲姟澶辫触锛屽鍣細{cntrString}锛岃捣鐐癸細{startLoc.S_CODE}"); + } + } + else + { + LogHelper.Info($"鐢熸垚绌烘墭鍑哄簱涓婄嚎浠诲姟澶辫触锛屼笉婊¤冻result.AgvAllow == 11 && result.Ready == 1"); + } + + }); + task.Wait(1000); + } + } + + /// <summary> + /// 婊℃墭杩囨湡鍑哄簱 婊℃墭杩囨湡鍥炲簱锛屾弧鎵樿繃鏈熷洖鐐�+ /// </summary> + internal static void FullOutTime() + { + try + { + var db = new SqlHelper<object>().GetInstance(); + + //婊℃墭杩囨湡鍑哄簱 + var startLoc_1 = db.Queryable<TN_Location>() + .LeftJoin<TN_Loc_Container>((o, i) => o.S_CODE == i.S_LOC_CODE) + .LeftJoin<TN_CG_Detail>((o, i, s) => i.S_CNTR_CODE == s.S_CNTR_CODE) + .Where((o, i, s) => s.N_ITEM_STATE == 3 && s.S_ITEM_STATE == "杩囨湡" + && o.S_AREA_CODE == Settings.Areas[1] && o.N_CURRENT_NUM > 0 + && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃�).First(); + + if (startLoc_1 != null) + { + var endLoc_1 = db.Queryable<TN_Location>() + .First(o => o.S_AREA_CODE == Settings.Areas[12] && + o.N_CURRENT_NUM == 0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃�); + + if (endLoc_1 != null) + { + var cntCode = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == startLoc_1.S_CODE); + var outTimeCg = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == cntCode.S_CNTR_CODE); + if (WCSHelper.CreateTask(startLoc_1.S_CODE, endLoc_1.S_CODE, "婊℃墭杩囨湡鍑哄簱", 3, outTimeCg.S_CNTR_CODE, outTimeCg.S_SPE)) + { + LocationHelper.LockLoc(startLoc_1.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc_1.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ LogHelper.Info($"鐢熸垚婊℃墭杩囨湡鍑哄簱浠诲姟鎴愬姛锛屽鍣ㄥ彿{outTimeCg.S_CNTR_CODE}锛岃捣鐐箋startLoc_1.S_CODE}锛岀粓鐐箋endLoc_1.S_CODE}"); + } + } + } + + + //婊℃墭杩囨湡鍥炲簱 + var startLoc_2 = db.Queryable<TN_Location>() + .LeftJoin<TN_Loc_Container>((o, i) => o.S_CODE == i.S_LOC_CODE) + .LeftJoin<TN_CG_Detail>((o, i, s) => i.S_CNTR_CODE == s.S_CNTR_CODE) + .Where((o, i, s) => s.N_ITEM_STATE == 0 && s.S_ITEM_STATE == "鍚堟牸" + && o.S_AREA_CODE == Settings.Areas[12] && o.N_CURRENT_NUM > 0 + && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃�).First(); + + } + catch (Exception ex) + { + LogHelper.Error($"鍙戠敓浜嗗紓甯革紝婊℃墭杩囨湡鍑哄簱 婊℃墭杩囨湡鍥炲簱锛屾弧鎵樿繃鏈熷洖鐐�寮傚父锛寋ex.Message}", ex); + } + } + + /// <summary> + /// 鍚屾TN_EquipProDetail绛夌瓑 + /// </summary> + internal static void SynchronizationEquipPro() + { + try + { + var db = new SqlHelper<object>().GetInstance(); + + // 鍚屾 TN_EquipProDetail 涓�TN_CG_Detail + var targetEPD = db.Queryable<TN_EquipProDetail>().LeftJoin<TN_CG_Detail>((o, i) => o.S_ID == i.S_ID). + Where((o, i) => o.ItemState != i.S_ITEM_STATE && i.S_ITEM_STATE != "寰呮").First(); + if (targetEPD != null) + { + targetEPD.ItemState = db.Queryable<TN_CG_Detail>().First(a => a.S_ID == targetEPD.S_ID).S_ITEM_STATE; + + db.Updateable<TN_EquipProDetail>(targetEPD).ExecuteCommand(); + } + + targetEPD = db.Queryable<TN_EquipProDetail>().LeftJoin<TN_CG_Detail>((o, i) => o.S_ID == i.S_ID). + Where((o, i) => System.DateTime.Now >= o.Expiration).First(); + if (targetEPD != null) + { + targetEPD.ItemState = "杩囨湡"; + db.Updateable<TN_EquipProDetail>(targetEPD).ExecuteCommand(); + + var cginfo = db.Queryable<TN_CG_Detail>().First(a => a.S_ID == targetEPD.S_ID); + cginfo.S_ITEM_STATE = "杩囨湡"; + cginfo.N_ITEM_STATE = 3; + db.Updateable<TN_CG_Detail>(cginfo).ExecuteCommand(); + } + + // 鍚屾 TN_DayProDetail + var curDay = System.DateTime.Now.Date; + var targetDay = db.Queryable<TN_DayProDetail>().First(a => a.DayTime == curDay); + if (targetDay == null) + { + targetDay = new TN_DayProDetail() + { + DayTime = curDay, + }; + db.Insertable(targetDay).ExecuteCommand(); + } + + var targetEPDs = db.Queryable<TN_EquipProDetail>().Where(a => a.DownLineTime >= curDay && a.DownLineTime <= curDay.AddDays(1)).ToList(); + + var sumWeight = targetEPDs.Sum(a => a.Weight); + + if (targetEPDs.Count > 0) + { + if (targetDay.Weight != sumWeight) + { + targetDay.Weight = sumWeight; + db.Updateable(targetDay).ExecuteCommand(); + } + + } + + // 鍚屾 TN_WeekProSpcDetail + var curWeek = System.DateTime.Now.Date.AddDays(-(int)System.DateTime.Now.DayOfWeek + 1); + var targetWeek = db.Queryable<TN_WeekProDetail>().First(a => a.DayTime == curWeek); + if (targetWeek == null) + { + targetWeek = new TN_WeekProDetail() + { + DayTime = curWeek, + }; + db.Insertable(targetWeek).ExecuteCommand(); + } + + targetEPDs = db.Queryable<TN_EquipProDetail>().Where(a => a.DownLineTime >= curWeek && a.DownLineTime <= curWeek.AddDays(7)).ToList(); + if (targetEPDs.Count > 0) + { + if (targetWeek.Weight != sumWeight) + { + targetWeek.Weight = sumWeight; + db.Updateable(targetWeek).ExecuteCommand(); + } + } + + // 鍚屾 TN_MonthProSpcDetail + var curMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).Date; + var targetMonth = db.Queryable<TN_MonthProDetail>().First(a => a.DayTime == curMonth); + if (targetMonth == null) + { + targetMonth = new TN_MonthProDetail() + { + DayTime = curMonth, + }; + db.Insertable(targetMonth).ExecuteCommand(); + } + targetEPDs = db.Queryable<TN_EquipProDetail>().Where(a => a.DownLineTime >= curMonth && a.DownLineTime <= curMonth.AddMonths(1)).ToList(); + if (targetEPDs.Count > 0) + { + if (targetMonth.Weight != sumWeight) + { + targetMonth.Weight = sumWeight; + db.Updateable(targetMonth).ExecuteCommand(); + } + } + + // 鍚屾 TN_YearProSpcDetail + var curYear = new DateTime(DateTime.Now.Year, 1, 1).Date; + var targetYear = db.Queryable<TN_YearProDetail>().First(a => a.DayTime == curYear); + if (targetYear == null) + { + targetYear = new TN_YearProDetail() + { + DayTime = curYear, + }; + db.Insertable(targetYear).ExecuteCommand(); + } + targetEPDs = db.Queryable<TN_EquipProDetail>().Where(a => a.DownLineTime >= curYear && a.DownLineTime <= curYear.AddYears(1)).ToList(); + if (targetEPDs.Count > 0) + { + if (targetYear.Weight != sumWeight) + { + targetYear.Weight = sumWeight; + db.Updateable(targetYear).ExecuteCommand(); + } + } + + // 鍚屾 TN_InventoryM 涓�TN_CG_Detail + var targetInM = db.Queryable<TN_InventoryM>().LeftJoin<TN_CG_Detail>((o, i) => o.S_ID == i.S_ID). + Where((o, i) => o.ItemState != i.S_ITEM_STATE && i.S_ITEM_STATE != "寰呮").First(); + if (targetInM != null) + { + targetInM.ItemState = db.Queryable<TN_CG_Detail>().First(a => a.S_ID == targetInM.S_ID).S_ITEM_STATE; + + db.Updateable<TN_InventoryM>(targetInM).ExecuteCommand(); + } + targetInM = db.Queryable<TN_InventoryM>().LeftJoin<TN_CG_Detail>((o, i) => o.S_ID == i.S_ID). + Where((o, i) => System.DateTime.Now >= o.Expiration).First(); + if (targetInM != null) + { + targetInM.ItemState = "杩囨湡"; + db.Updateable<TN_InventoryM>(targetInM).ExecuteCommand(); + + var cginfo = db.Queryable<TN_CG_Detail>().First(a => a.S_ID == targetInM.S_ID); + cginfo.S_ITEM_STATE = "杩囨湡"; + cginfo.N_ITEM_STATE = 3; + db.Updateable<TN_CG_Detail>(cginfo).ExecuteCommand(); + } + } + catch (Exception ex) + { + LogHelper.Error($"鍙戠敓浜嗗紓甯革紝鍚屾TN_EquipProDetail寮傚父锛寋ex.Message}", ex); + } + } + + /// <summary> + /// 鍚屾 TN_Container 鍧囪瀹炴椂鏄剧ず + /// </summary> + internal static void CheckCntAndBoard() + { + try + { + var db = new SqlHelper<object>().GetInstance(); + //鍚屾TN_Container + var fullLocList = db.Queryable<TN_Location>().Where(a => a.N_CURRENT_NUM > 0).ToList(); + if (fullLocList.Count > 0) + { + var fullLocCntList = db.Queryable<TN_Loc_Container>().Where(a => fullLocList.Select(b => b.S_CODE).ToList().Contains(a.S_LOC_CODE)).ToList(); + var fullLocCntListStr = fullLocCntList.Select(b => b.S_CNTR_CODE).ToList(); + var fullCntList = db.Queryable<TN_Container>().Where(a => fullLocCntListStr.Contains(a.S_CODE)).ToList(); + var fullCntListStr = fullCntList.Select(b => b.S_CODE).ToList(); + var except = fullLocCntListStr.Except(fullCntListStr).ToList(); + + if (except.Count > 0) + { + var addCntList = new List<TN_Container>(); + + foreach (var item in except) + { + addCntList.Add(new TN_Container() + { + S_CODE = item, + N_DETAIL_COUNT = 1 + }); + } + db.Insertable<TN_Container>(addCntList).ExecuteCommand(); + } + } + + var emptyCntList = db.Queryable<TN_Container>().Where(a => a.S_CODE != string.Empty && a.S_CODE != null).ToList(); + if (emptyCntList.Count > 0) + { + var emptyCntListStr = emptyCntList.Select(b => b.S_CODE).ToList(); + var emptyLocCntList = db.Queryable<TN_Loc_Container>().Where(a => emptyCntListStr.Contains(a.S_CNTR_CODE)).ToList(); + var emptyLocCntListStr = emptyLocCntList.Select(a => a.S_CNTR_CODE).ToList(); + var deleteCntList = emptyCntListStr.Except(emptyLocCntListStr).ToList(); + if (deleteCntList.Count > 0) + { + db.Deleteable<TN_Container>(emptyCntList).ExecuteCommand(); + } + } + + } + catch (Exception ex) + { + LogHelper.Error($"鍙戠敓浜嗗紓甯革紝鍚屾 TN_Container 寮傚父锛寋ex.Message}", ex); + } + } + + /// <summary> + /// 妫�祴婊℃墭缂撳瓨搴撳尯涓嶅悎鏍肩殑鐗╁搧锛屾弧鎵樺嚭搴撳妫�+ /// </summary> + internal static void CheckNoOkCg() + { + var db = new SqlHelper<object>().GetInstance(); + try + { + var endLoc = db.Queryable<TN_Location>().First(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.S_AREA_CODE == Settings.Areas[7]); + if (endLoc == null) + { + LogHelper.Info($"鏈壘鍒板悎閫傜殑缁堢偣璐т綅锛岃姹俛.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == 鏃�&& a.S_AREA_CODE == Settings.Areas[7]"); + return; + } + var startLoc = db.Queryable<TN_Location>(). + LeftJoin<TN_Loc_Container>((o, i) => o.S_CODE == i.S_LOC_CODE). + LeftJoin<TN_CG_Detail>((o, i, s) => i.S_CNTR_CODE == s.S_CNTR_CODE). + Where((o, i, s) => o.N_CURRENT_NUM == 1 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "鏃� && o.S_AREA_CODE == Settings.Areas[1] + && s.N_ITEM_STATE == 2 && s.S_ITEM_STATE == "涓嶅悎鏍�).First(); + + if (endLoc == null) + { + LogHelper.Info($"鏈壘鍒板悎閫傜殑璧风偣璐т綅锛岃姹俹.N_CURRENT_NUM == 1 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == 鏃�&& o.S_AREA_CODE == Settings.Areas[1] && s.N_ITEM_STATE ==2 && s.S_ITEM_STATE==涓嶅悎鏍�); + return; + } + + var cntId = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == startLoc.S_CODE); + if (cntId == null) + { + LogHelper.Info($"鏈壘鍒板搴旂殑瀹瑰櫒锛岃姹�a.S_LOC_CODE == startLoc.S_CODE"); + return; + } + + var cgInfo = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == cntId.S_CNTR_CODE); + + if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "婊℃墭鍑哄簱澶嶆", 3, cntId.S_CNTR_CODE, cgInfo.S_SPE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ + LogHelper.Info($"鐢熸垚婊℃墭鍑哄簱澶嶆浠诲姟鎴愬姛锛屽鍣細{cntId.S_CNTR_CODE}锛岃捣鐐癸細{startLoc.S_CODE}"); + } + else + { + LogHelper.Info($"鐢熸垚婊℃墭鍑哄簱澶嶆浠诲姟澶辫触锛屽鍣細{cntId.S_CNTR_CODE}锛岃捣鐐癸細{startLoc.S_CODE}"); + } + + + } + catch (Exception ex) + { + LogHelper.Error($"鍙戠敓浜嗗紓甯革紝鐢熸垚婊℃墭鍑哄簱澶嶆浠诲姟澶辫触锛寋ex.Message}", ex); + } + } + + /// <summary> + /// 绌烘墭鍫嗗彔鍏ュ簱 + /// </summary> + internal static void CheckEmptyCnt() + { + var db = new SqlHelper<object>().GetInstance(); + + try + { + var startLoc = db.Queryable<TN_Location>(). + Where(a => a.S_AREA_CODE == Settings.Areas[3] && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.N_CURRENT_NUM == a.N_CAPACITY). + OrderBy(a => a.T_MODIFY, OrderByType.Desc). + First(); + if (startLoc == null) + { + LogHelper.Info($"绌烘墭鍫嗗彔鍖簕Settings.Areas[3]}鏆傛棤鍫嗘弧鐨勭┖鎵�); + return; + } + + var endLoc = db.Queryable<TN_Location>(). + Where(a => a.S_AREA_CODE == Settings.Areas[4] && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y" && a.N_CURRENT_NUM == 0). + OrderBy(a => a.N_CURRENT_NUM, OrderByType.Asc). + First(); + + if (endLoc == null) + { + LogHelper.Info($"鏈壘鍒板悎閫傜殑缁堢偣璐т綅锛岄渶婊¤冻{Settings.Areas[4]}閲屾湁鏈攣瀹氫笖褰撳墠鏁伴噺绛変簬0鐨勮揣浣�); + return; + } + + var cntrList = db.Queryable<TN_Loc_Container>().Where(a => a.S_LOC_CODE == startLoc.S_CODE).OrderBy(a => a.T_CREATE, OrderByType.Asc).ToList(); + + if (cntrList.Count < 1) + { + LogHelper.Info($"璧风偣{startLoc.S_CODE}鏈壘鍒拌揣浣嶅鍣ㄥ叧绯讳俊鎭�); + return; + } + + string cntrString = ""; + for (int i = 0; i < cntrList.Count; i++) + { + if (i == cntrList.Count - 1)//鏈�悗涓�釜瀛楃涓茶繛鎺ヤ笉鍔犻�鍙�+ { + cntrString += cntrList[i].S_CNTR_CODE; + } + else + { + cntrString += cntrList[i].S_CNTR_CODE + ","; + } + } + + if (WCSHelper.CreateTask(startLoc.S_CODE, endLoc.S_CODE, "绌烘墭鍫嗗彔鍏ュ簱", 3, cntrString))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(startLoc.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ + LogHelper.Info($"鐢熸垚绌烘墭鍫嗗彔鍏ュ簱浠诲姟鎴愬姛锛屽鍣細{cntrString}锛岃捣鐐癸細{startLoc.S_CODE}"); + } + else + { + LogHelper.Info($"鐢熸垚绌烘墭鍫嗗彔鍏ュ簱浠诲姟澶辫触锛屽鍣細{cntrString}锛岃捣鐐癸細{startLoc.S_CODE}"); + } + } + catch (Exception ex) + { + LogHelper.Info($"绌烘墭鍫嗗彔鍏ュ簱寮傚父锛歿ex.Message}"); + } + + } + } + + /// <summary> + /// 涓嶴7璁惧浜や簰鏃剁殑model + /// </summary> + public class CheckDeciveModel + { + /// <summary> + /// 蹇冭烦 + /// </summary> + public int Heart { set; get; } + + /// <summary> + /// RFID锛屾槸瀹瑰櫒鏄墭鐩�+ /// </summary> + public string RfidData { set; get; } + + /// <summary> + /// 鍏佽涓婁笅鏂� 0=鏃犱换鍔★紝11=涓婃枡锛�1=涓嬫枡锛岋紙璇锋眰AGV宸ヤ綔锛�+ /// </summary> + public int AgvAllow { set; get; } + + /// <summary> + /// 浠诲姟灞炴� 1 OK锛�绉伴噸澶辫触锛�鏉$爜澶辫触锛� RFID璇诲彇澶辫触 + /// </summary> + public int TaskProperties { set; get; } + + /// <summary> + /// 鍑嗗灏辩华 0=鏈噯澶囧ソ锛�=鍑嗗濂�+ /// </summary> + public int Ready { set; get; } + + /// <summary> + /// 杞借揣鐘舵� 0=杈撻�绾挎棤浜у搧锛�=杈撻�绾挎湁浜у搧 + /// </summary> + public int CargoStatus { set; get; } + + /// <summary> + /// 宸ヤ綅鐘舵� 0寰呮満涓紝1鍏ュ簱鏂瑰悜杩愯涓紝2鍑哄簱鏂瑰悜杩愯涓紝3璁惧鏁呴殰 + /// </summary> + public int StationStatus { set; get; } + + /// <summary> + /// 鍘诲悜璇锋眰 0寰呮満涓紝1鍒颁綅璇锋眰 + /// </summary> + public int DestinationRequests { set; get; } + + /// <summary> + /// 鎵爜淇℃伅 鎵爜鏋弽棣堜俊鎭�+ /// </summary> + public string BarcodeCode { set; get; } + + /// <summary> + /// 閲嶉噺 + /// </summary> + public float Weight { set; get; } + + /// <summary> + /// 浜х嚎鍦板潃 + /// </summary> + public string LineIP { set; get; } + } +} + diff --git a/core/WCSCore.cs b/core/WCSCore.cs new file mode 100644 index 0000000..68267f1 --- /dev/null +++ b/core/WCSCore.cs @@ -0,0 +1,681 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.device; +using HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.process; +using HH.WCS.Mobox3.DoubleCoin.util; +using HH.WCS.Mobox3.DoubleCoin.wms; +using Newtonsoft.Json; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; + +namespace HH.WCS.Mobox3.DoubleCoin.core +{ + internal class WCSCore + { + public static ReturnResult OperateAgvTaskStatus(AgvTaskState model) + { + + var result = new ReturnResult(); + try + { + if (model.state == 1023 || model.state == 1025) + { + //鏃犱换鍔″彿璇锋眰(浜ょ锛屼氦閫氱鐞�寮�棬鍏抽棬锛屾棤浠诲姟鍙� + if(!DeviceProcess.OpenOrCloseDoor(model.lock_no, model.state)) + { + result.ResultCode = 2; + result.ResultMsg = $"TCP閫氳鍐欏叆澶辫触锛屽畨鍏ㄩ棬缂栧彿{model.lock_no}锛岀姸鎬亄model.state}"; + LogHelper.Info(result.ResultMsg, "API"); + return result; + } + } + else if (model.state == 1012) + { + Task task5 = Task.Run(() => + { + PostScanCode(model.task_no, model.forklift_no);//鍙嶉鎵爜缁撴灉 + }); + } + else if (model.state == 1004)//绉伴噸璐т綅璧风偣缁堢偣鏇存敼锛堜綑鏂欏洖搴撳拰鎷嗙洏鍥炲簱锛�+ { + Task task6 = Task.Run(() => + { + UpdateStartEnd(model.forklift_no); + }); + } + else if (model.state == 1103) + { + Task task7 = Task.Run(() => + { + CheckWeightDevice(model.forklift_no); + }); + } + else + { + var TN_Task = WCSHelper.GetTask(model.task_no);//鏍规嵁褰撳墠model缂栧彿鏌ヨ浠诲姟 + if (TN_Task != null) + { + if (model.state <= 8) + { + //鏈変换鍔$姸鎬佽姹�+ switch (model.state) + { + case 1: + WCSHelper.Begin(TN_Task, model.forklift_no);//宸叉帹閫佺殑浠诲姟鐨勭姸鎬佹敼鎴愭墽琛�+ Task task4 = Task.Run(() => + { + OpenScanCode(model.task_no, model.forklift_no);//寮�惎鎵爜 + }); + break; + case 3: + WCSHelper.UpdateStatus(TN_Task, "寮�鍙栬揣");//浠诲姟鐘舵�鏀规垚寮�鍙栬揣 + break; + case 4: + WCSHelper.UpdateStatus(TN_Task, "鍙栬揣瀹屾垚");//浠诲姟鐘舵�鏀规垚鍙栬揣瀹屾垚 + TaskProcess.OperateStatus(TN_Task, 4);//璧风偣瀹瑰櫒璐т綅瑙g粦,瑙i攣璧风偣 + + Task task3 = Task.Run(() => + { + EmptyInStackArea(TN_Task); + }); + + Task task1 = Task.Run(() => + { + returnS7Ok(TN_Task); + }); + + break; + case 5: + WCSHelper.UpdateStatus(TN_Task, "寮�鍗歌揣");//浠诲姟鐘舵�鏀规垚寮�鍗歌揣 + + break; + case 6: + WCSHelper.UpdateStatus(TN_Task, "鍗歌揣瀹屾垚");//浠诲姟鐘舵�鏀规垚鍗歌揣瀹屾垚 + TaskProcess.OperateStatus(TN_Task, 6);//缁堢偣瀹瑰櫒璐т綅缁戝畾,瑙i攣缁堢偣 + + Task task2 = Task.Run(() => + { + if (TN_Task.S_TYPE == "绌烘墭鍑哄簱鍏ョ嚎") + { + var ip = Settings.ProductionLines.FirstOrDefault(a => a.PointIn == TN_Task.S_END_LOC).ProductionLine_IP; + if (!Settings.S7TestMoni) + { + S7Helper.WriteBytes(ip, 10, 2, new byte[] { 0, 11, 1 }); + } + } + }); + + Task task29 = Task.Run(() => + { + if (TN_Task.S_TYPE == "浣欐枡涓嬬嚎鍏ュ簱") + { + SpecHelper.UpdateSurplusDetail(TN_Task.S_CODE); + } + }); + + Task task30 = Task.Run(() => + { + if (TN_Task.S_TYPE.Contains("鍥炵倝")) + { + SpecHelper.UpdateRemeltDetail(TN_Task.S_CODE); + } + }); + + Task task31 = Task.Run(() => + { + if (TN_Task.S_TYPE == "婊℃墭鍑哄簱涓婄嚎") + { + SpecHelper.UpdateComponentDetail(TN_Task.S_CODE); + } + }); + + + Task task12 = Task.Run(() => + { + if (TN_Task.S_TYPE == "PDA婊℃墭涓嬬嚎鍏ュ簱" || TN_Task.S_TYPE == "PLC婊℃墭涓嬬嚎鍏ュ簱") + { + SpecHelper.UpdateComponentDetail(TN_Task.S_CODE); + } + }); + + break; + case 2: + WCSHelper.End(TN_Task);//浠诲姟鐘舵�鏀规垚缁撴潫 + + break; + case 7: + Task task10 = Task.Run(() => + { + if (TN_Task.S_TYPE == "婊℃墭涓嬬嚎鍏ュ簱") + { + TaskProcess.OperateStatus(TN_Task, 7);//寮傚父澶勭悊 + } + else if(TN_Task.S_TYPE == "婊℃墭鍑哄簱涓婄嚎") + { + WCSHelper.Fail(TN_Task);//浠诲姟鐘舵�鏀规垚閿欒 + LocationHelper.UnLockLoc(TN_Task.S_END_LOC); + if (!WCSHelper.CheckActionRecordExist(TN_Task.S_CODE, 4)) + { + LocationHelper.UnLockLoc(TN_Task.S_START_LOC); + } + } + }); + + break; + case 8: + + Task task11 = Task.Run(() => + { + if (TN_Task.S_TYPE == "婊℃墭涓嬬嚎鍏ュ簱") + { + var res = NDCApi.CancelOrder(TN_Task.S_CODE); + if (res != null && (res.err_code ==50002 || res.err_code == 0)) + { + TaskProcess.OperateStatus(TN_Task, 7);//寮傚父澶勭悊 + } + else + { + LogHelper.Info($"寮傚父鍜屽彇娑堟搷浣�璇锋眰缁撴灉澶辫触{res}"); + } + } + else + { + var res = NDCApi.CancelOrder(TN_Task.S_CODE); + if (res != null && (res.err_code == 50002 || res.err_code == 0)) + { + WCSHelper.Fail(TN_Task);//浠诲姟鐘舵�鏀规垚閿欒 + LocationHelper.UnLockLoc(TN_Task.S_END_LOC); + if (!WCSHelper.CheckActionRecordExist(TN_Task.S_CODE, 4)) + { + LocationHelper.UnLockLoc(TN_Task.S_START_LOC); + } + } + else + { + LogHelper.Info($"寮傚父鍜屽彇娑堟搷浣�璇锋眰缁撴灉澶辫触{res}"); + } + + } + }); + break; + } + WCSHelper.AddActionRecord(model.task_no, model.state, model.forklift_no, model.ext_data); + //璋冪敤绗笁鏂规帴鍙o紙濡傛灉鏈夛級TaskProcess.ReportStatus锛屾坊鍔犱换鍔″姩浣滃叧绯昏〃 + } + else + { + //瀹夊叏璇锋眰绛�+ TaskProcess.OperateReq(model.task_no, model.state, model.forklift_no, model.ext_data); + } + + } + else + { + result.ResultCode = 1; + result.ResultMsg = $"鏍规嵁Model.No鏈壘鍒板搴旂殑浠诲姟锛寋model.task_no}"; + LogHelper.Info(result.ResultMsg,"API"); + return result; + } + } + + result.ResultCode = 0; + result.ResultMsg = "success"; + LogHelper.Info(result.ResultMsg, "API"); + return result; + } + catch(Exception ex) + { + result.ResultCode = -1; + result.ResultMsg = $"鍙戠敓浜嗗紓甯革細+{ex.Message}"; + LogHelper.Info(result.ResultMsg, "Error"); + return result; + } + } + + /// <summary> + /// 鏍¢獙绉伴噸璁惧 + /// </summary> + /// <param name="forklift_no"></param> + private static void CheckWeightDevice(string forklift_no) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var task = db.Queryable<TN_Task>().First(a => a.S_EQ_NO == forklift_no && a.N_B_STATE == 2); + if (task == null) + { + LogHelper.Info($"鏈壘鍒颁换鍔″彿淇℃伅锛屽搴旇溅鍙凤細{forklift_no}"); + return; + } + + var device = Settings.WeightDevices[0]; + if (device == null) + { + LogHelper.Info($"鏈湪閰嶇疆鏂囦欢閲屾壘鍒扮О閲嶈澶囦俊鎭�); + return; + } + var readRes = S7Helper.ReadBytes(device.WeightDevice_IP, 20, 6, 2); + LogHelper.Info($"绉伴噸璁惧DB20绗�浣�Byte锛岃鍙栫粨鏋滐細{BitConverter.ToString(readRes)}"); + if (readRes.Length==2 && readRes[1] == 1) + { + var res2 = NDCApi.ChangeOrderParam(task.S_CODE, 6, "1");//娣诲姞鏂板懡浠�+ if (res2.err_code != 0)//娣诲姞鏂板懡浠�+ { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护澶辫触锛屽弬鏁�鏀规垚1"); + return; + } + else + { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护鎴愬姛锛屽弬鏁�鏀规垚1"); + } + } + else + { + LogHelper.Info($"绉伴噸璁惧璇诲彇缁撴灉涓嶄负1锛屾棤娉曞弬鏁�鏀规垚1锛歿BitConverter.ToString(readRes)}"); + } + } + catch(Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯�{ex.Message}"); + } + } + + private async static void UpdateStartEnd(string forklift_no) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var task = db.Queryable<TN_Task>().First(a => a.S_EQ_NO == forklift_no && a.N_B_STATE ==2); + if (task == null) + { + LogHelper.Info($"鏈壘鍒颁换鍔″彿淇℃伅锛屽搴旇溅鍙凤細{forklift_no}"); + return; + } + var startLoc = db.Queryable<TN_Location>().First(a => a.S_CODE == Settings.WeightDevices[0].Point); + if (startLoc == null) + { + LogHelper.Info($"鏈壘鍒颁换鍔″彿鐨勮捣鐐逛俊鎭紝瀵瑰簲浠诲姟鍙凤細{task.S_CODE}"); + return; + } + + var device = Settings.WeightDevices[0]; + if (device == null) + { + LogHelper.Info($"鏈湪閰嶇疆鏂囦欢閲屾壘鍒扮О閲嶈澶囦俊鎭�); + return; + } + + if( S7Helper.WriteBytes(device.WeightDevice_IP, 10, 4, new byte[] { 0x01 })) + { + LogHelper.Info($"绉伴噸璁惧DB10鍐欏叆鍋忕Щ閲�涓�鎴愬姛"); + + await Task.Delay(500); // 寤惰繜 0.5 绉掞紝璁╁畠绉伴噸 + + var normal = S7Helper.ReadBytes(device.WeightDevice_IP, 20, 9, 1); + + if (normal.Length == 1 && normal[0] != 1 && normal[0] != 0) + { + LogHelper.Info($"绉伴噸璁惧DB20璇诲彇9锛岀粨鏋滄槸锛歿normal[0]}锛岀粨鏋滀笉涓�鎴�锛岃涓鸿澶囧紓甯�); + return; + } + + var readRes = S7Helper.ReadBytes(device.WeightDevice_IP, 20, 26, 2); + + LogHelper.Info($"绉伴噸璁惧璇诲彇缁撴灉DB20璇诲彇26浣�浣嶏細{BitConverter.ToString(readRes)}"); + + if (readRes.Length == 2) + { + var cginfo = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == task.S_CNTR_CODE); + if (cginfo == null) + { + LogHelper.Info($"鏈壘鍒板鍣ㄨ揣鍝佷俊鎭紝璇ュ鍣▄task.S_CNTR_CODE}"); + return; + } + var targetQty = BitConverter.ToInt16(readRes, 0); + + if (targetQty <= 0) + { + LogHelper.Info($"绉伴噸灏忎簬绛変簬0锛岀О閲峽targetQty}"); + return; + } + + var endloc = db.Queryable<TN_Location>().First(a => a.S_AREA_CODE == (cginfo.N_ITEM_STATE == 2 ? Settings.Areas[8] : Settings.Areas[1]) && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.N_CURRENT_NUM == 0); + + using (var trans = db.Ado.UseTran()) + { + if (cginfo.S_Separate_ID != null && cginfo.S_Separate_ID.Length > 0) + { + var target = db.Queryable<TN_CG_Detail>().First(a => a.S_Separate_ID == cginfo.S_Separate_ID && a.S_CNTR_CODE != cginfo.S_CNTR_CODE); + if (target.N_ITEM_STATE == 2) + { + target.F_QTY = cginfo.F_QTY - targetQty; + if(db.Updateable<TN_CG_Detail>(target).UpdateColumns(it => new { it.F_QTY }).ExecuteCommand() <= 0) + { + LogHelper.Info($"鏇存柊琚媶鐨勬柊瀹瑰櫒鐨勭墿鏂欓噸閲忓け璐ワ紝浠诲姟鍙凤細{task.S_CODE}锛岃捣鐐箋task.S_START_LOC}锛岀粓鐐箋task.S_END_LOC}"); + trans.RollbackTran(); + return; + } + } + } + cginfo.F_QTY = targetQty; + if(db.Updateable<TN_CG_Detail>(cginfo).UpdateColumns(it => new { it.F_QTY }).ExecuteCommand() <= 0) + { + LogHelper.Info($"鏇存柊褰撳墠瀹瑰櫒鐨勭墿鏂欓噸閲忓け璐ワ紝浠诲姟鍙凤細{task.S_CODE}锛岃捣鐐箋task.S_START_LOC}锛岀粓鐐箋task.S_END_LOC}"); + trans.RollbackTran(); + return; + } + + Task task31 = Task.Run(() => + { + if (task.S_TYPE == "浣欐枡涓嬬嚎鍏ュ簱") + { + SpecHelper.UpdateSurplusDetail(task.S_CODE, targetQty); + } + }); + + task.S_START_LOC = startLoc.S_CODE; + task.S_START_AREA = startLoc.S_AREA_CODE; + task.S_END_LOC = endloc.S_CODE; + task.S_END_AREA = endloc.S_AREA_CODE; + if (db.Updateable<TN_Task>(task).UpdateColumns(it => new { it.S_START_LOC, it.S_END_LOC, it.S_START_AREA, it.S_END_AREA }).ExecuteCommand() > 0) + { + LogHelper.Info($"璧风偣缁堢偣鍙傛暟鏇存柊鎴愬姛锛屼换鍔″彿锛歿task.S_CODE}锛岃捣鐐箋task.S_START_LOC}锛岀粓鐐箋task.S_END_LOC}"); + } + else + { + LogHelper.Info($"璧风偣缁堢偣鍙傛暟鏇存柊澶辫触锛屼换鍔″彿锛歿task.S_CODE}锛岃捣鐐箋task.S_START_LOC}锛岀粓鐐箋task.S_END_LOC}"); + trans.RollbackTran(); + return; + } + + var res2 = NDCApi.ChangeOrderParam(task.S_CODE, 1, startLoc.S_AGV_SITE); + if (res2 == null || res2.err_code != 0)//璧风偣 + { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护澶辫触锛屽弬鏁�鏀规垚璧风偣{startLoc.S_AGV_SITE}"); + trans.RollbackTran(); + return; + } + else + { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护鎴愬姛锛屽弬鏁�鏀规垚璧风偣{startLoc.S_AGV_SITE}"); + } + + res2 = NDCApi.ChangeOrderParam(task.S_CODE, 2, endloc.S_AGV_SITE);//缁堢偣鍙樿捣鐐�+ if (res2 == null || res2.err_code != 0)//缁堢偣鍙樿捣鐐�+ { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护澶辫触锛屽弬鏁�鏀规垚缁堢偣{ endloc.S_AGV_SITE}"); + trans.RollbackTran(); + return; + } + else + { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护鎴愬姛锛屽弬鏁�鏀规垚缁堢偣{endloc.S_AGV_SITE}"); + } + + res2 = NDCApi.ChangeOrderParam(task.S_CODE, 6, "2");//娣诲姞鏂板懡浠�+ if (res2.err_code != 0)//娣诲姞鏂板懡浠�+ { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护澶辫触锛屽弬鏁�鏀规垚2"); + trans.RollbackTran(); + return; + } + else + { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护鎴愬姛锛屽弬鏁�鏀规垚2"); + } + + res2 = NDCApi.ChangeOrderParam(task.S_CODE, 6, "1");//娣诲姞鏂板懡浠�+ if (res2.err_code != 0)//娣诲姞鏂板懡浠�+ { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护澶辫触锛屽弬鏁�鏀规垚1"); + trans.RollbackTran(); + return; + } + else + { + LogHelper.Info($"鏇存敼鍙傛暟鍛戒护鎴愬姛锛屽弬鏁�鏀规垚1"); + + } + trans.CommitTran(); + + + return; + } + } + else + { + LogHelper.Info($"绉伴噸璁惧璇诲彇缁撴灉锛屼笉绛変簬2涓狟yte"); + } + } + else + { + LogHelper.Info($"绉伴噸璁惧DB10鍐欏叆鍋忕Щ閲�涓�澶辫触"); + } + } + catch(Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯�{ex.Message}"); + } + } + + /// <summary> + /// 鍙嶉鎵爜缁撴灉 + /// </summary> + /// <param name="task_no"></param> + /// <param name="forklift_no"></param> + private static void PostScanCode(string task_no, string forklift_no) + { + try + { + var dic = new List<param>(); + var agv = Settings.AgvScanDevices.FirstOrDefault(a => a.AgvCode == forklift_no); + + if (agv == null) + { + LogHelper.Info($"鍦ㄩ厤缃〃涓湭鎵惧埌璇GV锛歿forklift_no}鐨勪俊鎭�); + return; + } + + if (!TcpServer.saoMa.ContainsKey(agv.ScanAddress)) + { + TcpServer.saoMa.Add(agv.ScanAddress,3); + } + + var res = NDCApi.ChangeOrderParam(task_no, 6, TcpServer.saoMa[agv.ScanAddress].ToString());//娣诲姞鏂板懡浠�+ if (res != null && (res.err_code == 0 || res.err_code == 50009)) + { + //鎺ㄩ�鎴愬姛 + LogHelper.Info($"NDC鍙嶉鎵爜缁撴灉鎴愬姛锛屾壂鐮佺粨鏋滐細{TcpServer.saoMa[agv.ScanAddress].ToString()}"); + + } + else + { + LogHelper.Info($"NDC鍙嶉鎵爜缁撴灉澶辫触锛屾壂鐮佺粨鏋滐細{TcpServer.saoMa[agv.ScanAddress].ToString()}"); + } + TcpServer.saoMa[agv.ScanAddress] = 3; + TcpServer.isCheck[agv.ScanAddress] = false; + } + catch (Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯�{ex.Message}"); + } + } + + /// <summary> + /// 浠诲姟鍒嗗彂锛屾牴鎹皟搴︾被鍨嬪彂缁欎笉鍚岀殑璋冨害绯荤粺 + /// </summary> + internal static void Dispatch() + { + //鏌ヨ浠诲姟 + //鑾峰彇鎵�湁绛夊緟鐨勪换鍔�+ var list = WCSHelper.GetWaitingTaskList(); + LogHelper.Info("绛夊緟浠诲姟淇℃伅" + JsonConvert.SerializeObject(list), "API"); + if (list.Count > 0) + { + list.ForEach(task => + { + //浣跨敤鑷畾涔変换鍔℃帹閫�+ TaskProcess.SendTask(task);//璋冨害NDC鎴栨澀濂ユ垨鍥借嚜璁惧 + //TaskProcess.SendGZTask(task);///璋冨害鍥借嚜璁惧 + + }); + } + else + { + LogHelper.Info("鏆傛棤浠诲姟"); + } + } + + /// <summary> + /// 鍥炲S7鍙栬揣瀹屾垚鍏抽棴淇″彿 + /// </summary> + /// <param name="tN_Task"></param> + public static void returnS7Ok(TN_Task tN_Task) + { + if (tN_Task.S_TYPE == "婊℃墭涓嬬嚎鍏ュ簱") + { + var ProductionLine = Settings.ProductionLines.FirstOrDefault(a => a.PointOut == tN_Task.S_START_LOC); + try + { + if (ProductionLine ==null) + { + LogHelper.Info($"浜х嚎鍑哄彛{tN_Task.S_START_LOC}锛岄厤缃枃浠舵湭鎵惧埌瀵瑰簲鐨凱ointOut鍊�); + return; + } + if (!Settings.S7TestMoni) + { + if (S7Helper.WriteBytes(ProductionLine.ProductionLine_IP, 10, 2, new byte[] { 0, 21, 1 })) + { + LogHelper.Info($"浜х嚎{ProductionLine.ProductionLine_IP}鍐欏叆DB10鐨勫亸绉�涓�, 21, 1锛�鍙栬揣瀹屾垚锛屾垚鍔�); + } + else + { + LogHelper.Info($"浜х嚎{ProductionLine.ProductionLine_IP}鍐欏叆DB10鐨勫亸绉�涓�, 21, 1锛�鍙栬揣瀹屾垚锛屽け璐�); + } + } + } + catch (Exception ex) + { + LogHelper.Info($"涓庝骇绾縶ProductionLine.ProductionLine_IP}鐨凷7 TCP閫氳澶辫触锛屽彂鐢熶簡寮傚父锛歿ex.Message}", "Error"); + } + } + } + + /// <summary> + /// 绌烘墭涓嬬嚎鍫嗗彔 + /// </summary> + /// <param name="tN_Task"></param> + public static void EmptyInStackArea(TN_Task tN_Task) + { + if (tN_Task.S_TYPE == "婊℃墭鍑哄簱涓婄嚎") + { + var result = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + try + { + var startLocLists = + db.Queryable<TN_Location>().Where(a => a.S_AREA_CODE == Settings.Areas[6] && a.N_CURRENT_NUM >0 && a.N_LOCK_STATE==0 && a.S_LOCK_STATE == "鏃�).ToList(); + + if (startLocLists.Count == 0) + { + LogHelper.Info($"浜哄伐鎵樼洏鍖烘殏鏃犲凡缁戝畾鐨勭┖鎵橈紝闇�婊¤冻锛氳揣浣嶆暟閲忓ぇ浜�锛屾湭閿佸畾鐨勶紝灞炰簬搴撳尯{Settings.Areas[6]}鐨勮揣浣�); + return; + } + + foreach (var item in startLocLists) + { + //鏌ヨ绗﹀悎鐨勬湭閿佸畾宸插惎鐢ㄦ寚瀹氳揣鍖虹殑褰撳墠鏁伴噺鍚堣鍚庢渶鎺ヨ繎瀹归噺鐨勮揣浣嶏紝缁堢偣 + var endLoc = db.Queryable<TN_Location>(). + Where(a => a.N_CURRENT_NUM + item.N_CURRENT_NUM <= a.N_CAPACITY && a.S_AREA_CODE == Settings.Areas[3] && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y"). + OrderBy(a => a.N_CURRENT_NUM + item.N_CURRENT_NUM - a.N_CAPACITY, OrderByType.Desc).First(); + + if (endLoc == null) + { + LogHelper.Info($"鏈壘鍒板悎閫傜殑缁堢偣锛岄渶瑕佹弧瓒筹細灞炰簬{Settings.Areas[3]}鐨勬湭閿佸畾鐨勫閲忓厖瓒崇殑璐т綅"); + continue; + } + var locCnt = db.Queryable<TN_Loc_Container>().First(a=>a.S_LOC_CODE == item.S_CODE); + + if (locCnt == null) + { + LogHelper.Info($"璐т綅{item.S_CODE}鏈粦瀹氬鍣�); + continue; + } + + //鍒涘缓绌烘墭涓嬬嚎鍫嗗彔浠诲姟 + if (WCSHelper.CreateTask(item.S_CODE, endLoc.S_CODE, "绌烘墭涓嬬嚎鍫嗗彔", 3, locCnt.S_CNTR_CODE))//鍒涘缓鎼�浠诲姟锛岃捣鐐圭粓鐐瑰鍣�+ { + LocationHelper.LockLoc(item.S_CODE, 2);//璧风偣鍑哄簱閿侊紝 + LocationHelper.LockLoc(endLoc.S_CODE, 1);//缁堢偣鍏ュ簱閿�+ + LogHelper.Info($"鐢熸垚绌烘墭涓嬬嚎鍫嗗彔浠诲姟鎴愬姛锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋item.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"); + } + else + { + LogHelper.Info($"鐢熸垚绌烘墭涓嬬嚎鍫嗗彔浠诲姟澶辫触锛屽鍣ㄥ彿{locCnt.S_CNTR_CODE}锛岃捣鐐箋item.S_CODE}锛岀粓鐐箋endLoc.S_CODE}"); + continue; + } + } + } + catch (Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯革細{ex.Message}", "Error"); + } + } + } + + /// <summary> + /// 寮�惎/鍏抽棴/璇诲崱鍣ㄦ壂鐮�+ /// </summary> + /// <returns></returns> + public static void OpenScanCode(string taskNo, string forklift_no) + { + try + { + var dic = new List<param>(); + var agv = Settings.AgvScanDevices.FirstOrDefault(a=>a.AgvCode == forklift_no); + + if (agv == null) + { + LogHelper.Info($"鍦ㄩ厤缃〃涓湭鎵惧埌璇GV锛歿forklift_no}鐨勪俊鎭�); + return; + } + + if (!TcpServer.isCheck.ContainsKey(agv.ScanAddress)) + { + TcpServer.isCheck.Add(agv.ScanAddress, false); + } + + string code = ""; + if (Settings.IsOpenScanCode) + { + code = "4"; + TcpServer.isCheck[agv.ScanAddress] = true; + } + else + { + code = "0"; + TcpServer.isCheck[agv.ScanAddress] = false; + } + + var res = NDCApi.ChangeOrderParam(taskNo,3, code);//娣诲姞鏂板懡浠�+ if (res != null && (res.err_code == 0 || res.err_code == 50009)) + { + //鎺ㄩ�鎴愬姛 + LogHelper.Info($"NDC鎺ㄩ�璇诲崱鍣ㄦ壂鐮佸弬鏁板彉鏇存垚鍔燂紝璇诲崱鍣ㄦ壂鐮佹槸鍚﹀紑鍚細{Settings.IsOpenScanCode}"); + } + else + { + LogHelper.Info($"NDC鎺ㄩ�璇诲崱鍣ㄦ壂鐮佸弬鏁板彉鏇村け璐ワ紝璇诲崱鍣ㄦ壂鐮佹槸鍚﹀紑鍚細{Settings.IsOpenScanCode}"); + } + } + catch(Exception ex) + { + + } + } + } +} diff --git a/core/WMSCore.cs b/core/WMSCore.cs new file mode 100644 index 0000000..ee7a884 --- /dev/null +++ b/core/WMSCore.cs @@ -0,0 +1,15 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.wms; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.core { + internal class WMSCore + { + + + } +} diff --git a/device/ModbusHelper.cs b/device/ModbusHelper.cs new file mode 100644 index 0000000..5acb3f4 --- /dev/null +++ b/device/ModbusHelper.cs @@ -0,0 +1,426 @@ +锘縰sing EasyModbus; +using HH.WCS.Mobox3.DoubleCoin; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.JunzhouNongfu.device +{ + /// <summary> + /// modbus tcp 鐢ㄧ涓夋柟鐨勫寘 + /// </summary> + public class ModbusHelper + { + public static Dictionary<string, ModbusClient> ipPort_ModbusClient = new Dictionary<string, ModbusClient>();//鍐呭瓨锛岃繛鎺ヤ笂鐨刴ocbus閫氳瀵硅薄 + + public ModbusHelper(string ip, int port) + { + Init(new ModbusConfigModel() { Ip = ip, Port = port }); + } + + /// <summary> + /// modbus鍚姩鍒濆鍖�+ /// </summary> + public static void Init(ModbusConfigModel modbusConfigModel) + { + //閰嶇疆鏂囦欢璇诲彇鎵�湁鐨刴ocbus杩涜鍒濆鍖�+ try + { + if (modbusConfigModel == null) + { + //璇诲彇閰嶇疆淇℃伅澶辫触 + return; + } + + var modbusClient = new ModbusClient(modbusConfigModel.Ip, modbusConfigModel.Port); + ipPort_ModbusClient.Add($"{modbusConfigModel.Ip}:{modbusConfigModel.Port}", modbusClient); + Link(modbusClient); + } + catch (Exception ex) + { + + } + } + + /// <summary> + /// 杩炴帴modbus涓嬩綅鏈�+ /// </summary> + /// <param name="modbusClient"></param> + private static void Link(ModbusClient modbusClient) + { + try + { + modbusClient.Disconnect(); + modbusClient.Connect(); + if (modbusClient.Connected) + { + //杩炴帴涓�+ } + else + { + //娌¤繛涓�+ } + } + catch (Exception ex) + { + + } + } + + /// <summary> + /// 閲嶈繛 + /// </summary> + internal static void RestLink() + { + if (ipPort_ModbusClient.Count > 0) + { + foreach (var item in ipPort_ModbusClient) + { + if (!item.Value.Connected) + { + Link(item.Value); + } + } + } + } + + /// <summary> + /// 璇讳竴涓垨澶氫釜绾垮湀锛岃繑鍥炰竴涓猙it鐪熷亣鏁扮粍 + /// </summary> + /// <param name="address"></param> + /// <param name="qty"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + /// <returns></returns> + public static bool[] ReadCoils(int address, int qty, string ip, int port = 502) + { + bool[] res = new bool[0]; + var client = GetModbusClient(ip, port); + if (client != null && client.Connected) + { + try + { + res = client.ReadCoils(address, qty); + if (res.Length != 0) + { + //璇诲彇鎴愬姛 + } + else + { + //璇诲彇澶辫触 + } + } + catch (Exception ex) + { + + } + } + else + { + + } + return res; + } + + /// <summary> + /// 鍐欏叆鍗曚釜绾垮湀 + /// </summary> + /// <param name="address"></param> + /// <param name="value"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + public static bool WriteSingleCoil(int address, bool value, string ip, int port = 502) + { + var res = false; + var client = GetModbusClient(ip, port); + if (client != null && client.Connected) + { + try + { + client.WriteSingleCoil(address, value); + res = value == client.ReadCoils(address, 1)[0]; + if (res) + { + //鍐欏叆鎴愬姛 + } + else + { + //鍐欏叆澶辫触 + } + } + catch (Exception ex) + { + + } + } + else + { + + } + return res; + } + /// <summary> + /// 鍐欏叆澶氫釜绾垮湀 + /// </summary> + /// <param name="address"></param> + /// <param name="values"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + public static bool WriteMultipleCoils(int address, bool[] values, string ip, int port = 502) + { + var res = false; + var client = GetModbusClient(ip, port); + if (client != null && client.Connected) + { + try + { + client.WriteMultipleCoils(address, values); + var dataRead = client.ReadCoils(address, values.Length); + res = values.SequenceEqual(dataRead); + if (res) + { + //鍐欏叆鎴愬姛 + } + else + { + //鍐欏叆澶辫触 + } + } + catch (Exception ex) + { + + } + } + else + { + + } + return res; + + } + + /// <summary> + /// 鎵归噺璇诲彇鎴栧崟鐙鍙栦繚鎸佸瘎瀛樺櫒锛岃繑鍥炵殑鏄�2浣峣nt鏁扮粍 + /// </summary> + /// <param name="address">璇诲彇璧峰浣�/param> + /// <param name="qty">璇诲彇鐨勬暟閲�/param> + /// <param name="ip">IP鍦板潃</param> + /// <param name="port">绔彛鍙�/param> + /// <returns></returns> + public static int[] ReadHoldingRegisters(int address, int qty, string ip, int port = 502) + { + int[] res = new int[0]; + var client = GetModbusClient(ip, port); + if (client != null && client.Connected) + { + try + { + //涓�釜瀵勫瓨鍣ㄦ槸16浣嶏紝杩斿洖2涓猧nt绫诲瀷 + res = client.ReadHoldingRegisters(address, qty); + if (res.Length != 0) + { + //璇诲彇鎴愬姛 + } + else + { + //璇诲彇澶辫触 + } + } + catch (Exception ex) + { + //濡傛灉璇锋眰鏁伴噺瓒呭嚭淇濇寔瀵勫瓨鍣ㄧ殑鏈�ぇ鏁版嵁琛屾暟锛屼細鎶ラ敊 + LogHelper.Info($"鍙戠敓浜嗗紓甯�{ex.Message},IP:{ip},Port:{port}", "Error"); + } + } + else + { + LogHelper.Info($"鏈壘鍒癕odbus璁惧瀹炰緥瀵硅薄:IP:{ip},Port:{port}"); + } + return res; + } + + /// <summary> + /// 鍐欏叆鍗曚釜瀵勫瓨鍣ㄦ暟鎹�+ /// </summary> + /// <param name="address"></param> + /// <param name="value"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + public static bool WriteSingleRegister(int address, int value, string ip, int port = 502) + { + var res = false; + var client = GetModbusClient(ip, port); + if (client != null && client.Connected) + { + try + { + client.WriteSingleRegister(address, value); + res = value == client.ReadHoldingRegisters(address, 1)[0]; + if (res) + { + //鍐欏叆鎴愬姛 + } + else + { + //鍐欏叆澶辫触 + } + } + catch (Exception ex) + { + + } + } + else + { + + } + return res; + } + + /// <summary> + /// 鍐欏叆澶氫釜瀵勫瓨鍣ㄦ暟鎹�+ /// </summary> + /// <param name="address"></param> + /// <param name="values"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + public static bool WriteMultipleRegisters(int address, int[] values, string ip, int port = 502) + { + var res = false; + var client = GetModbusClient(ip, port); + var log = string.Join(",", values.Select(x => x.ToString())); + if (client != null && client.Connected) + { + try + { + client.WriteMultipleRegisters(address, values); + var dataRead = client.ReadHoldingRegisters(address, values.Length); + res = values.SequenceEqual(dataRead); + if (res) + { + LogHelper.Info($"鍐欏叆鎴愬姛,IP:{ip},Port:{port},{log}"); + } + else + { + LogHelper.Info($"鍐欏叆澶辫触,IP:{ip},Port:{port},{log}"); + } + } + catch (Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯�{ex.Message},IP:{ip},Port:{port},{log}","Error"); + } + } + else + { + LogHelper.Info($"鏈厤缃殑璁惧淇℃伅,IP:{ip},Port:{port},{log}"); + } + return res; + } + + /// <summary> + /// 璇讳竴涓垨澶氫釜绂绘暎杈撳叆锛岃繑鍥炰竴涓猙it鐪熷亣鏁扮粍 + /// </summary> + /// <param name="address"></param> + /// <param name="qty"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + /// <returns></returns> + public static bool[] ReadDiscreteInputs(int address, int qty, string ip, int port = 502) + { + bool[] res = new bool[0]; + var client = GetModbusClient(ip, port); + if (client != null && client.Connected) + { + try + { + res = client.ReadDiscreteInputs(address, qty); + if (res.Length != 0) + { + //璇诲彇鎴愬姛 + } + else + { + //璇诲彇澶辫触 + } + } + catch (Exception ex) + { + + } + } + else + { + + } + return res; + + } + + /// <summary> + /// 璇讳竴涓垨澶氫釜杈撳叆瀵勫瓨鍣紝杩斿洖涓�釜int32浣嶆暟缁�+ /// </summary> + /// <param name="address"></param> + /// <param name="qty"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + /// <returns></returns> + public static int[] ReadInputRegisters(int address, int qty, string ip, int port = 502) + { + int[] res = new int[0]; + var client = GetModbusClient(ip, port); + if (client != null && client.Connected) + { + try + { + res = client.ReadInputRegisters(address, qty); + if (res.Length != 0) + { + //璇诲彇鎴愬姛 + } + else + { + //璇诲彇澶辫触 + } + } + catch (Exception ex) + { + + } + } + else + { + + } + return res; + } + + /// <summary> + /// 鑾峰彇modbus閫氳瀵硅薄 + /// </summary> + /// <param name="ip"></param> + /// <param name="port"></param> + /// <returns></returns> + private static ModbusClient GetModbusClient(string ip, int port) + { + if (ipPort_ModbusClient.ContainsKey($"{ip}:{port}")) + { + return ipPort_ModbusClient[$"{ip}:{port}"]; + } + else + { + return null; + } + } + + /// <summary> + /// 閫氳繃Modbus鍗忚杩炴帴涓嬩綅鏈烘椂闇�鐨刴odel锛屽簲璇ユ斁鍦╩odel灞傦紝杩欓噷鎴戞噿浜�+ /// </summary> + public class ModbusConfigModel + { + public string Ip { set; get; }//IP鍦板潃 + public int Port { set; get; }//绔彛鍙�+ } + } +} diff --git a/device/OpcUaHelper.cs b/device/OpcUaHelper.cs new file mode 100644 index 0000000..20682f2 --- /dev/null +++ b/device/OpcUaHelper.cs @@ -0,0 +1,193 @@ +锘縰sing Opc.Ua.Client; +using Opc.Ua; +using System; +using Opc.Ua.Configuration; + + +namespace HH.WCS.Mobox3.DoubleCoin.device +{ + internal class OpcUaHelper + { + private static Opc.Ua.Client.Session session; + + static OpcUaHelper() + { + CreateUpcSession(); + } + + /// <summary> + /// 杩炴帴OPC鏈嶅姟 + /// </summary> + internal static async void CreateUpcSession() + { + try + { + // 鍒涘缓涓�釜搴旂敤閰嶇疆瀵硅薄锛岀敤浜庤缃簲鐢ㄥ悕绉般�鍞竴鏍囪瘑銆佺被鍨嬨�璇佷功鍜屽畨鍏ㄧ瓥鐣�+ var config = new ApplicationConfiguration() + { + ApplicationName = "MyClient", + ApplicationUri = Utils.Format(@"urn:{0}:MyClient", System.Net.Dns.GetHostName()), + ApplicationType = ApplicationType.Client, + SecurityConfiguration = new SecurityConfiguration + { + ApplicationCertificate = new CertificateIdentifier { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\MachineDefault", SubjectName = "MyClientSubjectName" }, + TrustedIssuerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\UA Certificate Authorities" }, + TrustedPeerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\UA Applications" }, + RejectedCertificateStore = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\RejectedCertificates" }, + AutoAcceptUntrustedCertificates = true, + RejectSHA1SignedCertificates = false, + MinimumCertificateKeySize = 1024, + NonceLength = 32, + }, + TransportConfigurations = new TransportConfigurationCollection(), + TransportQuotas = new TransportQuotas { OperationTimeout = 15000 }, + ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 }, + TraceConfiguration = new TraceConfiguration() + }; + + // 楠岃瘉搴旂敤閰嶇疆瀵硅薄 + await config.Validate(ApplicationType.Client); + + // 璁剧疆璇佷功楠岃瘉浜嬩欢锛岀敤浜庤嚜鍔ㄦ帴鍙椾笉鍙椾俊浠荤殑璇佷功 + if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates) + { + config.CertificateValidator.CertificateValidation += (s, e) => { e.Accept = (e.Error.StatusCode == StatusCodes.BadCertificateUntrusted); }; + } + + // 鍒涘缓涓�釜搴旂敤瀹炰緥瀵硅薄锛岀敤浜庢鏌ヨ瘉涔�+ var application = new ApplicationInstance(config); + + // 妫�煡搴旂敤瀹炰緥瀵硅薄鐨勮瘉涔�+ bool check = await application.CheckApplicationInstanceCertificate(false, 2048); + // 鍒涘缓涓�釜浼氳瘽瀵硅薄锛岀敤浜庤繛鎺ュ埌 OPC UA 鏈嶅姟鍣�+ EndpointDescription endpointDescription = CoreClientUtils.SelectEndpoint("opc.tcp://172.16.57.41:4840", true); + EndpointConfiguration endpointConfiguration = EndpointConfiguration.Create(config); + ConfiguredEndpoint endpoint = new ConfiguredEndpoint(null, endpointDescription, endpointConfiguration); + session = await Session.Create(config, endpoint, false, false, "DataCollector", 60000, new UserIdentity(), null); + if (session != null && session.Connected) + { + Console.WriteLine("The session is connected to the OPC UA server."); + LogHelper.Info($"鍒涘缓OPC杩炴帴鎴愬姛", "OPC"); + } + else + { + Console.WriteLine("The session is not connected to the OPC UA server."); + LogHelper.Info($"鍒涘缓OPC杩炴帴澶辫触", "OPC"); + } + } + catch (Exception e) + { + LogHelper.Info($"杩炴帴OPC鏈嶅姟寮傚父" + e.Message, "OPC"); + } + } + + /// <summary> + /// 璇诲彇OPC鑺傜偣鏁版嵁 + /// </summary> + /// <param name="nodeId"></param> + internal static object ReadOpcValue(string nodeId) + { + try + { + if (session != null && session.Connected) + { + // 璇诲彇鏁版嵁鑺傜偣 + DataValue item = session.ReadValue(nodeId: nodeId); + LogHelper.Info($"OPC璇诲彇:nodeid:{nodeId},value:{item.Value}", "OPC"); + return item.Value; + } + else + { + Console.WriteLine("The session is not connected to the OPC UA server."); + LogHelper.Info($"OPC杩炴帴澶辫触", "OPC"); + CreateUpcSession(); + } + + } + catch (Exception e) + { + + LogHelper.Info($"璇诲彇OPC鏁版嵁寮傚父" + e.Message, "OPC"); + } + return null; + } + + /// <summary> + /// 鍐橭PC鑺傜偣鏁版嵁 + /// </summary> + /// <param name="nodeId"></param> + /// <param name="val"></param> + internal static void WriteOpcValue(string nodeId,bool val) + { + try + { + if (session != null && session.Connected) + { + // 鍐欏叆鏁版嵁鍒拌妭鐐�+ WriteValue writeValue = new WriteValue + { + NodeId = new NodeId(nodeId), + AttributeId = Attributes.Value, + Value = new DataValue(val) + }; + + StatusCodeCollection results; + DiagnosticInfoCollection diagnosticInfos; + session.Write(null, new WriteValueCollection { writeValue }, out results, out diagnosticInfos); + Console.WriteLine($"Write Status for {nodeId}: {results[0]}"); + LogHelper.Info($"OPC鍐欏叆:nodeid:{nodeId},value:{val}", "OPC"); + } + else + { + Console.WriteLine("The session is not connected to the OPC UA server."); + LogHelper.Info($"OPC杩炴帴澶辫触", "OPC"); + CreateUpcSession(); + } + + } + catch (Exception e) + { + LogHelper.Info($"鍐欏叆OPC鏁版嵁寮傚父" + e.Message, "OPC"); + } + } + + /// <summary> + /// 鍐橭PC鑺傜偣鏁版嵁 + /// </summary> + /// <param name="nodeId"></param> + /// <param name="val"></param> + internal static void WriteOpcValue(string nodeId, int val) + { + try + { + if (session != null && session.Connected) + { + // 鍐欏叆鏁版嵁鍒拌妭鐐�+ WriteValue writeValue = new WriteValue + { + NodeId = new NodeId(nodeId), + AttributeId = Attributes.Value, + Value = new DataValue(val) + }; + + StatusCodeCollection results; + DiagnosticInfoCollection diagnosticInfos; + session.Write(null, new WriteValueCollection { writeValue }, out results, out diagnosticInfos); + Console.WriteLine($"Write Status for {nodeId}: {results[0]}"); + LogHelper.Info($"OPC鍐欏叆:nodeid:{nodeId},value:{val}", "OPC"); + } + else + { + Console.WriteLine("The session is not connected to the OPC UA server."); + LogHelper.Info($"OPC杩炴帴澶辫触", "OPC"); + CreateUpcSession(); + } + + } + catch (Exception e) + { + LogHelper.Info($"鍐欏叆OPC鏁版嵁寮傚父" + e.Message, "OPC"); + } + } + } +} diff --git a/device/PlcHelper.cs b/device/PlcHelper.cs new file mode 100644 index 0000000..99245f1 --- /dev/null +++ b/device/PlcHelper.cs @@ -0,0 +1,99 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.process; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.device +{ + internal class PlcHelper + { + internal static void Receive(string ip, string msg) { + //澶勭悊璁惧淇″彿 + DeviceProcess.Analysis(msg, ip); + } + internal static bool SendHex(string ip, string msg) { + return TcpServer.TcpServerSend(ip, Hex2Bytes(msg)); + + } + internal static void SendAscii(string ip, string msg) { + TcpServer.TcpServerSend(ip, Encoding.ASCII.GetBytes(msg)); + } + + internal static byte[] Hex2Bytes(string hexString) { + hexString = hexString.Replace(" ", ""); + if ((hexString.Length % 2) != 0) + hexString += " "; + byte[] returnBytes = new byte[hexString.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16); + + return returnBytes; + } + internal static string Hex2Ascii(string hexString) { + hexString = hexString.Replace(" ", ""); + if ((hexString.Length % 2) != 0) + hexString += " "; + byte[] returnBytes = new byte[hexString.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16); + + return Encoding.ASCII.GetString(returnBytes); + } + + #region 杩涘埗杞崲+CRC + internal static bool CheckCRC(string hex) { + var result = false; + var data = hex.Replace(" ", ""); + if (data.Length % 2 == 0) { + var code1 = data.Substring(data.Length - 4, 4).ToLower(); + var code2 = BitConverter.ToString(CRC16LH(Hex2Bytes(data.Substring(0, data.Length - 4)))).Replace("-", "").Replace(" ", "").ToLower(); + result = code1 == code2; + } + return result; + } + internal static byte[] CRC16LH(byte[] pDataBytes) { + ushort crc = 0xffff; + ushort polynom = 0xA001; + + for (int i = 0; i < pDataBytes.Length; i++) { + crc ^= pDataBytes[i]; + for (int j = 0; j < 8; j++) { + if ((crc & 0x01) == 0x01) { + crc >>= 1; + crc ^= polynom; + } + else { + crc >>= 1; + } + } + } + + byte[] result = BitConverter.GetBytes(crc); + return result; + } + internal static byte[] CRC16HL(byte[] pDataBytes) { + ushort crc = 0xffff; + ushort polynom = 0xA001; + + for (int i = 0; i < pDataBytes.Length; i++) { + crc ^= pDataBytes[i]; + for (int j = 0; j < 8; j++) { + if ((crc & 0x01) == 0x01) { + crc >>= 1; + crc ^= polynom; + } + else { + crc >>= 1; + } + } + } + + byte[] result = BitConverter.GetBytes(crc).Reverse().ToArray(); + return result; + } + + #endregion + } +} diff --git a/device/S7Helper.cs b/device/S7Helper.cs new file mode 100644 index 0000000..30f80bb --- /dev/null +++ b/device/S7Helper.cs @@ -0,0 +1,423 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.api; +using Newtonsoft.Json.Linq; +using S7.Net; +using S7.Net.Types; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web.Services.Description; + +namespace HH.WCS.Mobox3.DoubleCoin.device +{ + + /// <summary> + /// 瑗块棬瀛恜lc + /// </summary> + public class S7Helper + { + public static Dictionary<string, Plc> ip_Plc = new Dictionary<string, Plc>();//鍐呭瓨锛岃繛鎺ヤ笂鐨凱LC閫氳瀵硅薄 + + public S7Helper(string ip, short rack, short slot) + { + Init(new S7ConfigModel() { Ip = ip, Rack = rack, Slot = slot, CpuType = CpuType.S71500 }); + } + + /// <summary> + /// S7鍚姩鍒濆鍖�+ /// </summary> + public static void Init(S7ConfigModel s7ConfigInfo) + { + //閰嶇疆鏂囦欢璇诲彇鎵�湁鐨刾lc杩涜鍒濆鍖�+ try + { + if (s7ConfigInfo == null) + { + //璇诲彇閰嶇疆淇℃伅澶辫触 + return; + } + + var plc = new Plc(s7ConfigInfo.CpuType, s7ConfigInfo.Ip, s7ConfigInfo.Rack, s7ConfigInfo.Slot); + ip_Plc.Add(s7ConfigInfo.Ip, plc); + Link(plc); + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + } + + /// <summary> + /// 閲嶈繛 + /// </summary> + public static void RestLink() + { + if (ip_Plc.Count>0) + { + foreach (var item in ip_Plc) + { + if(!item.Value.IsConnected) + { + Link(item.Value); + } + } + } + } + + + /// <summary> + /// 杩炴帴PLC + /// </summary> + /// <param name="plc"></param> + private static void Link(Plc plc) + { + try + { + plc.Close(); + plc.Open(); + if (plc.IsConnected) + { + LogHelper.Info($"杩炴帴涓妠plc.IP}");//杩炴帴涓�+ } + else + { + LogHelper.Info($"娌¤繛涓妠plc.IP}");//娌¤繛涓�+ } + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + } + + /// <summary> + /// 鎵归噺璇诲彇鎴栧崟鐙鍙朌B鍧楁暟鎹紙8浣峛yte锛夛紝骞惰浆鎹㈡垚瀛楃涓插舰寮�+ /// </summary> + /// <param name="deviceIp">plc璁惧閫氳鍦板潃</param> + /// <param name="dbNo">DB鍧楀彿</param> + /// <param name="startByteAdr">璧峰byte鍦板潃锛屾渶灏忓�0锛�=8浣�1涓狟lock</param> + /// <param name="count">璇诲彇鐨勪釜鏁帮紝1涓�8浣嶅崄鍏繘鍒舵暟</param> + /// <returns></returns> + public static string ReadString(string deviceIp, int dbNo, int startByteAdr, int count) + { + string result = ""; + try + { + var plc = GetPlc(deviceIp); + if (plc != null) + { + if (plc.IsConnected) + { + var data = plc.ReadBytes(DataType.DataBlock, dbNo, startByteAdr, count); + result = System.Text.Encoding.UTF8.GetString(data).TrimEnd('\0').TrimEnd('\n').TrimEnd('\r'); ;//姝ゆ柟娉曞彲浠ユ妸byte鏁扮粍杞崲鎴愬瓧绗︿覆锛屼絾鏄細閫犳垚\0\u缁撴潫绗︿笉鏄剧ず锛岄渶瑕佷笅浣嶆満姝g‘鐨勬暟鎹�+ if (result == string.Empty) + { + Link(plc);//璁惧鍙戦�鐨勬暟鎹负绌猴紝閲嶈繛 + } + } + else + { + Link(plc);//璁惧鏈繛鎺ワ紝閲嶈繛 + } + } + else + { + LogHelper.Info($"涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥�");//涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥� + } + + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + return result; + } + + /// <summary> + /// 鎵归噺鍐欏叆鎴栧崟鐙啓鍏B鍧楁暟鎹紙8浣峛yte锛夛紝浠ュ瓧绗︿覆杞崲byte褰㈠紡鍐欏叆 + /// </summary> + /// <param name="deviceIp">plc璁惧閫氳鍦板潃</param> + /// <param name="dbNo">DB鍧楀彿</param> + /// <param name="startByteAdr">璧峰byte鍦板潃锛屾渶灏忓�0锛�=8浣�1涓狟lock</param> + /// <param name="data">瑕佸啓鍏ョ殑鏁版嵁</param> + /// <returns></returns> + public static bool WriteString(string deviceIp, int dbNo, int startByteAdr, string data) + { + var result = false; + try + { + var plc = GetPlc(deviceIp); + if (plc != null) + { + if (plc.IsConnected) + { + byte[] bytes = System.Text.Encoding.UTF8.GetBytes(data); + plc.WriteBytes(DataType.DataBlock, dbNo, startByteAdr, bytes); + + if (!result) + { + //鍐欏畬鍐嶈涓�纭 + var readData = ReadString(deviceIp, dbNo, startByteAdr, data.Length); + result = readData == data; + } + } + else + { + Link(plc);//璁惧鏈繛鎺ワ紝閲嶈繛 + } + } + else + { + //涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥� + } + + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + return result; + } + + /// <summary> + /// 鎵归噺璇诲彇鎴栧崟鐙鍙朌B鍧楁暟鎹紙8浣峛yte锛�+ /// </summary> + /// <param name="deviceIp">plc璁惧閫氳鍦板潃</param> + /// <param name="dbNo">DB鍧楀彿</param> + /// <param name="startByteAdr">璧峰byte鍦板潃锛屾渶灏忓�0锛�=8浣�1涓狟lock</param> + /// <param name="count">璇诲彇鐨勪釜鏁帮紝1涓�8浣嶅崄鍏繘鍒舵暟</param> + /// <returns></returns> + public static byte[] ReadBytes(string deviceIp, int dbNo, int startByteAdr, int count) + { + byte[] result = null; + try + { + var plc = GetPlc(deviceIp); + if (plc != null) + { + if (plc.IsConnected) + { + result = plc.ReadBytes(DataType.DataBlock, dbNo, startByteAdr, count); + + if (result.Length == 0) + { + Link(plc);//璁惧鍙戦�鐨勬暟鎹负绌猴紝閲嶈繛 + } + } + else + { + Link(plc);//璁惧鏈繛鎺ワ紝閲嶈繛 + } + } + else + { + LogHelper.Info($"涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥�");//涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥� + } + + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + return result; + } + + /// <summary> + /// 鎵归噺鍐欏叆鎴栧崟鐙啓鍏B鍧楁暟鎹紙8浣峛yte锛�+ /// </summary> + /// <param name="deviceIp">plc璁惧閫氳鍦板潃</param> + /// <param name="dbNo">DB鍧楀彿</param> + /// <param name="startByteAdr">璧峰byte鍦板潃锛屾渶灏忓�0锛�=8浣�1涓狟lock</param> + /// <param name="data">瑕佸啓鍏ョ殑鏁版嵁</param> + /// <returns></returns> + public static bool WriteBytes(string deviceIp, int dbNo, int startByteAdr, byte[] data) + { + var result = false; + try + { + var plc = GetPlc(deviceIp); + if (plc != null) + { + if (plc.IsConnected) + { + plc.WriteBytes(DataType.DataBlock, dbNo, startByteAdr, data); + + if (!result) + { + //鍐欏畬鍐嶈涓�纭 + var readData = ReadBytes(deviceIp, dbNo, startByteAdr, data.Length); + result = readData.SequenceEqual(data); + } + } + else + { + Link(plc);//璁惧鏈繛鎺ワ紝閲嶈繛 + } + } + else + { + LogHelper.Info($"涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥�");//涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥� + } + + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + return result; + } + + /// <summary> + /// 鎵归噺璇诲彇鎴栧崟鐙鍙朌B鍧楁暟鎹紙1浣峛it锛�+ /// </summary> + /// <param name="deviceIp">plc璁惧閫氳鍦板潃</param> + /// <param name="dbNo">DB鍧楀彿</param> + /// <param name="startByteAdr">璧峰byte鍦板潃锛屾渶灏忓�0锛�=8浣�1涓狟lock</param> + /// <param name="count">瑕佽鍙栧灏戜綅</param> + /// <param name="bitAdr">浠庣鍑犱綅寮�璇诲彇</param> + /// <returns></returns> + public static BitArray ReadBits(string deviceIp, int dbNo, int startByteAdr, int count, byte bitAdr = 0) + { + BitArray result = null; + try + { + var plc = GetPlc(deviceIp); + if (plc != null) + { + if (plc.IsConnected) + { + var data = plc.Read(DataType.DataBlock, dbNo, startByteAdr, VarType.Bit, count, bitAdr); + if (count == 1) + { + result = new BitArray(new bool[] { (bool)data }); + } + else + { + result = (BitArray)data; + } + if (result.Length == 0) + { + Link(plc);//璁惧鍙戦�鐨勬暟鎹负绌猴紝閲嶈繛 + } + } + else + { + Link(plc);//璁惧鏈繛鎺ワ紝閲嶈繛 + } + } + else + { + LogHelper.Info($"涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥�");//涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥� + } + + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + return result; + } + + /// <summary> + /// 鎵归噺鍐欏叆鎴栧崟鐙啓鍏B鍧楁暟鎹紙1浣峛it锛�+ /// </summary> + /// <param name="deviceIp">plc璁惧閫氳鍦板潃</param> + /// <param name="dbNo">DB鍧楀彿</param> + /// <param name="startByteAdr">璧峰byte鍦板潃锛屾渶灏忓�0锛�=8浣�1涓狟lock</param> + /// <param name="biteAdr">璧峰bit鍦板潃锛屼粠绗嚑浣嶅紑濮嬪啓k</param> + /// <param name="bitValue">瑕佸啓鍏ョ殑鏁版嵁</param> + /// <returns></returns> + public static bool WriteBits(string deviceIp, int dbNo, int startByteAdr, byte biteAdr, BitArray bitValue) + { + var result = false; + try + { + var plc = GetPlc(deviceIp); + if (plc != null) + { + if (plc.IsConnected) + { + for (int i = 0; i < bitValue.Length; i++) + { + plc.WriteBit(DataType.DataBlock, dbNo, startByteAdr, biteAdr + i, bitValue[i]); + } + + if (!result) + { + //鍐欏畬鍐嶈涓�纭 + var readData = ReadBits(deviceIp, dbNo, startByteAdr, bitValue.Length, biteAdr); + result = CompareBitArray(readData, bitValue); + } + } + else + { + Link(plc);//璁惧鏈繛鎺ワ紝閲嶈繛 + } + } + else + { + LogHelper.Info($"涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥�");//涓嶅瓨鍦ㄧ殑璁惧銆傞厤缃枃浠朵腑鏄惁鍖呭惈鍏惰澶囥� + } + + } + catch (Exception ex) + { + LogHelper.Info($"{ex.Message}\r\n{ex.StackTrace}"); + } + return result; + } + + /// <summary> + /// 鑾峰彇PLC璇诲啓瀵硅薄 + /// </summary> + /// <param name="plc"></param> + /// <returns></returns> + private static Plc GetPlc(string plc) + { + if (ip_Plc.ContainsKey(plc)) + { + return ip_Plc[plc]; + } + else + { + return null; + } + } + + /// <summary> + /// 姣旇緝涓や釜浜岃繘鍒剁殑鏁板�鏄惁鐩稿悓 + /// </summary> + /// <param name="b1"></param> + /// <param name="b2"></param> + /// <returns></returns> + private static bool CompareBitArray(BitArray b1, BitArray b2) + { + bool result = true; + b1.Xor(b2).Not();//寮傛垨鎿嶄綔 鐒跺悗 闈炴搷浣�+ + foreach (var item in b1) + { + if (!(bool)item) + { + result = false; + break; + } + } + return result; + } + + /// <summary> + /// 閫氳繃S7鍗忚杩炴帴涓嬩綅鏈烘椂闇�鐨刴odel锛屽簲璇ユ斁鍦╩odel灞傦紝杩欓噷鎴戞噿浜�+ /// </summary> + public class S7ConfigModel + { + public CpuType CpuType { set; get; }//鍗忚绫诲瀷 + public string Ip { set; get; }//IP鍦板潃 + public short Rack { set; get; }//鏋跺瓙鍙�+ public short Slot { set; get; }//鎻掓Ы鍙�+ } + + } +} diff --git a/device/ScanCodeHelper.cs b/device/ScanCodeHelper.cs new file mode 100644 index 0000000..415ed2b --- /dev/null +++ b/device/ScanCodeHelper.cs @@ -0,0 +1,95 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.util; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.device +{ + /// <summary> + /// 灏忚溅璇诲崱鍣ㄩ�杩嘥CPServer鍙戦�娑堟伅瀛樺偍鍦ㄨ繖 + /// </summary> + public class ScanCodeHelper + { + public static Dictionary<string, ScanInfoModel> scanInfoDic = new Dictionary<string, ScanInfoModel>();//鍐呭瓨淇℃伅缂撳瓨 + + /// <summary> + /// 鏍¢獙RFID + /// </summary> + /// <param name="address"></param> + /// <param name="data"></param> + /// <returns></returns> + public static bool Analysis(string address, string data) + { + var agvScan = Settings.AgvScanDevices.FirstOrDefault(a => a.ScanAddress == address); + if (agvScan != null) + { + ScanInfoModel scanInfoModel = new ScanInfoModel(); + scanInfoModel.AgvCode = agvScan.AgvCode; + scanInfoModel.AgvAddress = agvScan.ScanAddress; + scanInfoModel.RFID = data;//杩欓噷瑕佺瓫閫�+ + if (scanInfoDic.ContainsKey(agvScan.AgvCode)) + { + scanInfoDic[agvScan.AgvCode] = scanInfoModel; + } + else + { + scanInfoDic.Add(agvScan.AgvCode, scanInfoModel); + } + + return GetRFIDByAgvCode(scanInfoModel.AgvCode, scanInfoModel.RFID); + } + else + { + LogHelper.Info("鍦ㄩ厤缃〃涓湭鎵惧埌璇ヨ鍗″櫒鍦板潃锛� + address + "鐨勪俊鎭�, "TCP"); + } + return false; + } + + internal static bool GetRFIDByAgvCode(string agvCode,string RFID) + { + var db = new SqlHelper<TN_Task>().GetInstance(); + var task = new TN_Task(); + task = db.Queryable<TN_Task>().Where(a => a.S_EQ_NO == agvCode && a.N_B_STATE == 2).OrderByDescending(b => b.T_CREATE).First(); + if (task != null && RFID.Contains(task.S_CNTR_CODE)) + { + LogHelper.Info($"鏍¢獙鎴愬姛Agv锛歿agvCode}瀹瑰櫒鍙凤細{RFID}"); + return true; + } + else + { + LogHelper.Info($"鏍¢獙澶辫触Agv锛歿agvCode}瀹瑰櫒鍙凤細{RFID}"); + + //鏍¢獙澶辫触灏卞彇娑堜换鍔�+ //var task1 = Task.Run(() => + //{ + // if (task != null) + // { + // var res = NDCApi.ChangeOrderParam(task.S_CODE, 6, "2"); + // LogHelper.Info($"AGV鏍¢獙RFID澶辫触锛屽彂閫佸彇娑堜换鍔″懡浠ゅ弬鏁�鏀逛负2锛屼换鍔″彿{task.S_CODE}"); + // if (res.err_code==0) + // { + // LogHelper.Info($"AGV鏍¢獙RFID澶辫触锛屽彂閫佸彇娑堜换鍔″懡浠ゅ弬鏁�鏀逛负2锛屼换鍔″彿{task.S_CODE}锛岀粨鏋滐細鍙栨秷鎴愬姛"); + // } + // else + // { + // LogHelper.Info($"AGV鏍¢獙RFID澶辫触锛屽彂閫佸彇娑堜换鍔″懡浠ゅ弬鏁�鏀逛负2锛屼换鍔″彿{task.S_CODE}锛岀粨鏋滐細鍙栨秷澶辫触锛歿res.err_msg}"); + // } + // } + //}); + + return false; + } + } + } + + public class ScanInfoModel + { + public string AgvCode { get; set; }//agv缂栧彿 + public string AgvAddress { get; set; }//agv璇诲崱鍣ㄥ湴鍧�+ public string RFID { get; set; }//agv璇诲崱鍣ㄤ笂鎶ョ殑RFID锛屾墭鐩�+ } +} diff --git a/device/TcpClient.cs b/device/TcpClient.cs new file mode 100644 index 0000000..e6d199d --- /dev/null +++ b/device/TcpClient.cs @@ -0,0 +1,85 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin; +using HH.WCS.Mobox3.DoubleCoin.device; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.device { + internal class TcpClient + { + /// <summary> + /// + /// </summary> + /// <param name="ip">127.0.0.1</param> + /// <param name="port">8888</param> + /// <param name="hex">01 02 00 00 00 0C 78 0F</param> + /// <returns></returns> + private static string SendHexOnce(string ip, int port, string hex) { + var res = string.Empty; + Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + client.Connect(ip, port); + client.ReceiveTimeout = 2000; + if (client.Connected) { + client.Send(PlcHelper.Hex2Bytes(hex)); + byte[] buffer = new byte[1024]; + try { + var length = client.Receive(buffer, SocketFlags.None); + byte[] data = new byte[length]; + Array.Copy(buffer, data, length); + res = BitConverter.ToString(data).Replace("-", ""); + } + catch (Exception ex) { + LogHelper.Error(ex.Message, ex); + } + client.Disconnect(true); + client.Dispose(); + } + client = null; + return res; + } + + /// <summary> + /// 璇讳繚鎸佸瘎瀛樺櫒锛宮odbus rtu鐨勫皝瑁�+ /// </summary> + /// <param name="address"></param> + /// <param name="qty"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + /// <returns></returns> + internal int[] ReadInputRegistersRtu(int address, int qty, string ip, int port = 502) { + List<int> res = new List<int>(); + var hex = $"0103{address.ToString("X4")}{qty.ToString("X4")}"; + hex = hex + BitConverter.ToString(PlcHelper.CRC16LH(PlcHelper.Hex2Bytes(hex))).Replace("-", "").Replace(" ", ""); + var data = SendHexOnce(ip, port, hex); + if (!string.IsNullOrEmpty(data)) { + if (PlcHelper.CheckCRC(data)) { + var lenght = Convert.ToInt16(data.Substring(4, 2), 16) / 2; + for (int i = 0; i < lenght; i++) { + res[i] = Convert.ToInt16(data.Substring(6 + 4 * 1, 4), 16); + } + } + } + return res.ToArray(); + } + /// <summary> + /// 鍐欏崟涓瘎瀛樺櫒 + /// </summary> + /// <param name="address"></param> + /// <param name="value"></param> + /// <param name="ip"></param> + /// <param name="port"></param> + internal bool WriteSingleRegisterRtu(int address, int value, string ip, int port = 502) { + var res = false; + var hex = $"0106{address.ToString("X4")}{value.ToString("X4")}"; + hex = hex + BitConverter.ToString(PlcHelper.CRC16LH(PlcHelper.Hex2Bytes(hex))).Replace("-", "").Replace(" ", ""); + var data = SendHexOnce(ip, port, hex); + if (!string.IsNullOrEmpty(data)) { + res = true; + } + return res; + } + } +} diff --git a/device/TcpServer.cs b/device/TcpServer.cs new file mode 100644 index 0000000..bea90aa --- /dev/null +++ b/device/TcpServer.cs @@ -0,0 +1,277 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; + +namespace HH.WCS.Mobox3.DoubleCoin.device +{ + public class TcpServer + { + public TcpServer(string ip, int port) + { + Init(ip, port); + } + private void Init(string ip, int port) + { + //鍒涘缓涓�釜鏂扮殑Socket,杩欓噷鎴戜滑浣跨敤鏈�父鐢ㄧ殑鍩轰簬TCP鐨凷tream Socket锛堟祦寮忓鎺ュ瓧锛�+ var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + try + { + //灏嗚socket缁戝畾鍒颁富鏈轰笂闈㈢殑鏌愪釜绔彛锛岀鍙e簲璇ユ斁鍒伴厤缃枃浠朵腑 + socket.Bind(new IPEndPoint(IPAddress.Parse(ip), port)); + Console.WriteLine(port); + //鍚姩鐩戝惉锛屽苟涓旇缃竴涓渶澶х殑闃熷垪闀垮害 + socket.Listen(30); + //寮�鎺ュ彈瀹㈡埛绔繛鎺ヨ姹�+ socket.BeginAccept(new AsyncCallback(ClientAccepted), socket); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + public static Dictionary<string, Socket> clients = new Dictionary<string, Socket>(); + public static Dictionary<string, byte[]> buffers = new Dictionary<string, byte[]>(); + public static Dictionary<string,bool> isSend = new Dictionary<string, bool>(); + public static Dictionary<string,bool> isCheck = new Dictionary<string, bool>(); + + public static Dictionary<string,int> saoMa = new Dictionary<string, int>(); + + public static void ClientAccepted(IAsyncResult ar) + { + + var socket = ar.AsyncState as Socket; + var client = socket.EndAccept(ar); + string remote_ip = ((System.Net.IPEndPoint)client.RemoteEndPoint).Address.ToString(); + if (clients.Keys.Contains(remote_ip)) + { + clients[remote_ip] = client; + } + else + { + clients.Add(remote_ip, client); + } + if (!buffers.Keys.Contains(remote_ip)) + { + buffers.Add(remote_ip, new byte[1024]); + } + + if (!isSend.Keys.Contains(remote_ip)) + { + isSend.Add(remote_ip, false); + } + + if (!isCheck.Keys.Contains(remote_ip)) + { + isCheck.Add(remote_ip, false); + } + + //缁欏鎴风鍙戦�涓�釜娆㈣繋娑堟伅 + //client.Send(Encoding.Unicode.GetBytes("Hi there, I accept you request at " + DateTime.Now.ToString())); + Console.WriteLine(remote_ip); + + try + { + client.BeginReceive(buffers[remote_ip], 0, buffers[remote_ip].Length, SocketFlags.None, new AsyncCallback(ReceiveMessage), client); + } + catch (Exception ex) + { + Console.WriteLine($"銆愭帴鏀跺鎴风鐨勬秷鎭紓甯搞�锛� + ex.Message); + } + //鍑嗗鎺ュ彈涓嬩竴涓鎴风璇锋眰 + socket.BeginAccept(new AsyncCallback(ClientAccepted), socket); + } + + + public static void ReceiveMessage(IAsyncResult ar) + { + try + { + var socket = ar.AsyncState as Socket; + string remote_ip = ((System.Net.IPEndPoint)socket.RemoteEndPoint).Address.ToString(); + var length = socket.EndReceive(ar); + if (length == 0) + { + clients.Remove(remote_ip); + buffers.Remove(remote_ip); + isSend.Remove(remote_ip); + isCheck.Remove(remote_ip); + saoMa.Remove(remote_ip); + return; + } + else + { + if (!clients.Keys.Contains(remote_ip)) + { + clients.Add(remote_ip, socket); + } + if (!buffers.Keys.Contains(remote_ip)) + { + buffers.Add(remote_ip, new byte[1024]); + + } + if (!isSend.Keys.Contains(remote_ip)) + { + isSend.Add(remote_ip, false); + } + if (!isCheck.Keys.Contains(remote_ip)) + { + isCheck.Add(remote_ip, false); + } + if (!saoMa.Keys.Contains(remote_ip)) + { + saoMa.Add(remote_ip, 3); + } + } + + //LogHelper.Info($"鎺ユ敹鍒颁俊鎭紝IP锛歿remote_ip},MSG锛歿BitConverter.ToString(buffers[remote_ip])}"); + + if (buffers.Keys.Contains(remote_ip)) + { + var messageBytes = new byte[length]; + Array.Copy(buffers[remote_ip], 0, messageBytes, 0, length); + + try + { + //璇诲崱鍣ㄦ牎楠�+ var message = BitConverter.ToString(messageBytes); + + if (!saoMa.ContainsKey(remote_ip)) + { + saoMa.Add(remote_ip, 3); + } + if (messageBytes.Length <= 20 && messageBytes.Length > 0) + { + saoMa[remote_ip] = 3;//鏈壂鍒扮爜 + } + + if (messageBytes.Length >= 21 && isCheck[remote_ip]) + { + byte[] rfid = new byte[12]; + Array.Copy(messageBytes, 9, rfid, 0, 12); + + string rfids16 = BitConverter.ToString(rfid); + string rfids = Encoding.ASCII.GetString(rfid); + LogHelper.Info($"璇诲崱鍣ㄦ牎楠屽搴斿鍣ㄥ彿锛歿rfids}锛屽叾16杩涘埗褰㈠紡锛歿rfids16}"); + if (ScanCodeHelper.Analysis(remote_ip, rfids))//鏍¢獙RFID + { + isCheck[remote_ip] = true; + saoMa[remote_ip] = 1;//鎵爜鍖归厤 + } + else + { + isCheck[remote_ip] = true; + saoMa[remote_ip] = 2;//鎵爜涓嶅尮閰�+ } + } + else + { + LogHelper.Info($"涓嶆弧瓒宠鍗″櫒鏍¢獙瑙勫畾锛欼P锛歿remote_ip},MSG锛歿message}"); + } + } + catch(Exception ex) + { + LogHelper.Info($"鎵爜鏍¢獙鍙戠敓浜嗗紓甯革細{ex.Message}"); + saoMa[remote_ip] = 4;//鎵爜寮傚父 + } + + try + { + //鍗峰笜闂ㄥ紑鍏�+ var plc = Settings.SafeDoorDevices.FirstOrDefault(a => a.IPAddress == remote_ip); + var log = string.Join(",", messageBytes.Select(x => x.ToString())); + if (plc != null && + messageBytes[0] == 0x3F && + messageBytes[1] == 0x00 && + messageBytes[2] == 0x11 && + messageBytes[3] == 0x0d && + messageBytes[4] == 0x0a && isSend[remote_ip]) + { + LogHelper.Info($"{plc.DeviceName}璁惧寮�棬瀹屾垚锛寋log}"); + + var dic = new List<param>(); + dic.Add(new param() { name = "From", value = "1" }); + dic.Add(new param() { name = "To", value = plc.DeviceCode }); + + var resAgv = NDCApi.AddOrderNew(164, 1, System.DateTime.Now.Ticks.ToString(), dic); + LogHelper.Info($"閫氱煡AGV閫氳繃瀹夊叏闂紝杩斿洖缁撴灉锛歿JsonConvert.SerializeObject(resAgv)}璁惧寮�棬瀹屾垚"); + if (resAgv.err_code == 0) + { + isSend[remote_ip] = false; + } + } + else + { + LogHelper.Info($"{remote_ip}璁惧杩斿洖锛歿log}"); + } + } + catch(Exception ex) + { + LogHelper.Info($"鍗峰笜闂ㄦ牎楠屽彂鐢熶簡寮傚父锛歿ex.Message}"); + } + //TcpServerSend(remote_ip, System.Text.Encoding.Default.GetBytes(msgSend)); + Array.Clear(buffers[remote_ip], 0, buffers[remote_ip].Length);//娓呯┖褰撳墠IP Buffer + } + else + { + if (!buffers.Keys.Contains(remote_ip)) + { + buffers.Add(remote_ip, new byte[1024]); + } + } + + //鎺ユ敹涓嬩竴涓秷鎭�鍥犱负杩欐槸涓�釜閫掑綊鐨勮皟鐢紝鎵�互杩欐牱灏卞彲浠ヤ竴鐩存帴鏀舵秷鎭簡锛�+ socket.BeginReceive(buffers[remote_ip], 0, buffers[remote_ip].Length, SocketFlags.None, new AsyncCallback(ReceiveMessage), socket); + } + catch (Exception ex) + { + + } + } + + private static string GetHexString(byte[] buffer, int lenght) + { + return BitConverter.ToString(buffer, 0, lenght).Replace("-", string.Empty).ToLower(); + } + + public static bool TcpServerSend(string ip, byte[] msg) + { + if (clients.Keys.Contains(ip)) + { + var client = clients[ip]; + if (client.Connected) + { + try + { + client.Send(msg); + LogHelper.Info($"宸插彂閫佺粰璇GV鍦板潃{ip}锛寋msg}"); + return true; + } + catch (SocketException ex) + { + LogHelper.Info(ex.Message, "Error"); + clients[ip].Close(); + clients.Remove(ip); + } + } + else + { + clients[ip].Close(); + clients.Remove(ip); + } + } + else + { + LogHelper.Info("鏈壘鍒拌璁惧锛屾槸鍚﹀凡杩炴帴锛�); + } + return false; + + } + + } +} diff --git a/dispatch/GZRobot.cs b/dispatch/GZRobot.cs new file mode 100644 index 0000000..90c1fd8 --- /dev/null +++ b/dispatch/GZRobot.cs @@ -0,0 +1,395 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.core; +using HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Web.Caching; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; + +namespace HH.WCS.Mobox3.DoubleCoin.dispatch +{ + /// <summary> + /// 鍥借嚜璋冨害杈呭姪绫�+ /// </summary> + public class GZRobot + { + private static readonly HttpHelper apiHelper = new HttpHelper(); + private static readonly string baseUrl = "";//閰嶇疆鏂囦欢鑾峰彇鍥借嚜璋冨害鍦板潃 + //private static readonly string logName = "guozi"; + public static List<IOState> GetIO() { + var result = apiHelper.Get(baseUrl + "api/engine/view/iostates/"); + var data = JsonConvert.DeserializeObject<gzResult<IOState>>(result); + return data.data; + } + public static void UpdateIOState() { + var data = new { data = new List<IOSateInfo>() }; + var result = apiHelper.Post(baseUrl + "api/engine/tasks/iostates/", JsonConvert.SerializeObject(data)); + var dataResult = JsonConvert.DeserializeObject<gzResult<IOStatesInfoResult>>(result); + } + + public static int CreateOrder(string taskNo, int priority, string param, string ts = "churuku",string created_user="hanhe") { + LogHelper.Info($"CreateOrder鍙傛暟淇℃伅:taskNo:{taskNo},priority:{priority},param:{param},ts:{ts}锛宑reated_user锛歿created_user}", "API"); + var msg = ""; + var orderId = 0; + var data = new OrderInfo() { order_name = taskNo, priority = priority, dead_line = DateTime.Now, ts_name = ts, parameters = param ,created_user=created_user}; + var request = JsonConvert.SerializeObject(data); + var response = apiHelper.Post(baseUrl + "api/om/order/", request); + LogHelper.Info($"CreateOrder:url:{baseUrl}api/om/order/,request:{request}", "API"); + msg = $"[guozi-CreateOrder] request={request} response={response}"; + Console.WriteLine(msg); + if (response != "") { + try { + var dataResult = JsonConvert.DeserializeObject<gzResult<OrderInfoResult>>(response); + if (dataResult.code == 0) { + orderId = dataResult.data[0].in_order_id; + } + } + catch (Exception ex) { + } + } + else { + msg = "[guozi-CreateOrder]鍒涘缓璁㈠崟澶辫触"; + Console.WriteLine(msg); + LogHelper.Info($"鍒涘缓璁㈠崟澶辫触", "API"); + } + + + return orderId; + } + public static bool CancelOrder(int orderId) { + bool result = false; + string msg = ""; + var request = new CancelOrderInfo() { order_list = new List<int>(orderId) }; + var response = apiHelper.Post(baseUrl + "api/om/order/cancel/", JsonConvert.SerializeObject(request)); + msg = $"[guozi-CancelOrder] request={request};response={response}"; + Console.WriteLine(msg); + if (response != "") { + var dataResult = JsonConvert.DeserializeObject<gzResult<CancelOrderInfoResult>>(response); + if (dataResult.code == 0) { + result = true; + } + } + else { + msg = "[guozi-CancelOrder]鍙栨秷璁㈠崟澶辫触"; + Console.WriteLine(msg); + } + return result; + } + + public static bool CancelGZOrder(int orderId) + { + bool result = false; + string msg = ""; + List<CancelGZOrderInfo> requests = new List<CancelGZOrderInfo>(); + var request = new CancelGZOrderInfo() { order_id = orderId, order_command_type_id = 2 }; + requests.Add(request); + var response = apiHelper.Put(baseUrl + "api/om/order/order-command/", JsonConvert.SerializeObject(requests)); + msg = $"[guozi-CancelOrder] request={requests};response={response}"; + if (response != "") + { + var dataResult = JsonConvert.DeserializeObject<CancelGZOrderResult>(response); + if (dataResult.code == 0) + { + msg = "[guozi-CancelOrder]鍙栨秷璁㈠崟鎴愬姛"; + Console.WriteLine(msg); + result = true; + return result; + } + } + else + { + msg = "[guozi-CancelOrder]鍙栨秷璁㈠崟澶辫触"; + Console.WriteLine(msg); + } + return result; + } + + + /// <summary> + /// 璁㈠崟鐘舵�鍙嶉 + /// </summary> + /// <returns></returns> + public static GzResult orderStatusReport(orderStatusReportParme model) + { + GzResult result = new GzResult(); + AgvTaskState agv = new AgvTaskState(); + + if (model == null) + { + result.resultCode = 1; + result.orderID = model.orderID; + result.msg = "杩斿洖璁㈠崟鐘舵�澶辫触"; + } + + switch (model.orderStatus) + { + case "active": + agv.state = 1; + break; + case "waiting": + agv.state = 1; + break; + case "source_finish": + //鍙栬揣瀹屾垚 + agv.state = 4; + break; + case "dest_finish": + //鍗歌揣瀹屾垚 + agv.state = 6; + break; + case "finish": + agv.state = 2; + break; + case "manually_finish": + agv.state = 2; + break; + case "cancel_finish": + agv.state = 7; + break; + case "error": + agv.state = 7; + break; + default: + agv.state = 0; + break; + } + if (agv.state != 0) + { + agv.task_no = model.orderName; + agv.forklift_no = model.agvIDList; + WCSCore.OperateAgvTaskStatus(agv); + } + + result.resultCode = 0; + result.msg = "杩斿洖璁㈠崟鐘舵�鎴愬姛"; + result.orderID = model.orderID; + LogHelper.Info("orderStatusReport杩斿洖淇℃伅" + JsonConvert.SerializeObject(result), "API"); + return result; + } + + + + public class CancelGZOrderInfo + { + public int order_id { get; set; } + + public int order_command_type_id { get; set; } + + } + + + public static QueryOrderResult QueryOrder(int id) { + // + var result = new QueryOrderResult() { agv_list = new List<int> { 0 } }; + string msg = ""; + var response = apiHelper.Get(baseUrl + $"/api/om/order/{id}/"); + msg = $"[guozi-QueryOrderResult] request={id};response={response}"; + Console.WriteLine(msg); + if (response != "") { + var data = JsonConvert.DeserializeObject<gzResult<QueryOrderResult>>(response); + result = data.data[0]; + } + else { + msg = "[guozi-QueryOrderResult]鏌ヨ璁㈠崟淇℃伅澶辫触"; + Console.WriteLine(msg); + } + return result; + } + /// <summary> + /// 鑾峰彇浜や簰淇℃伅 + /// </summary> + /// <param name="typeId">1浠诲姟鐘舵� 2寮�棬鎴栦氦绠� 3鐩殑鐐�/param> + /// <param name="status"></param> + /// <returns></returns> + public static List<InteractInfoResult> QueryInteractInfo(int typeId, string status = "active") { + + //string aaa = "{\"app_name\": \"Gouzi client\", \"version\": \"1.0.0\", \"code\": 0, \"msg\": \"success\", \"data\": [{\"interaction_info_id\": 233, \"interaction_info_name\": \"TN2012030001\", \"interaction_info_desp\": null, \"interaction_info_type_id\": 3, \"value_json\": {\"state\": \"4\"}, \"info_status\": \"active\", \"return_value\": null}]}"; + //var data = JsonConvert.DeserializeObject<gzResult<InteractInfoResult>>(aaa); + var list = new List<InteractInfoResult>(); + string msg = ""; + var result = apiHelper.Get(baseUrl + $"api/om/interaction_info/find_by_type/?type_id={typeId}&info_status={status}"); + if (!string.IsNullOrEmpty(result)) { + Console.WriteLine(result); + // {"app_name": "Gouzi client", "version": "1.0.0", "code": 0, "msg": "success", "data": [{"interaction_info_id": 230, "interaction_info_name": "2", "interaction_info_desp": null, "interaction_info_type_id": 3, "value_json": {"state": "4"}, "info_status": "active", "return_value": null}, {"interaction_info_id": 231, "interaction_info_name": "2", "interaction_info_desp": null, "interaction_info_type_id": 3, "value_json": {"state": "6"}, "info_status": "active", "return_value": null}, {"interaction_info_id": 232, "interaction_info_name": "2", "interaction_info_desp": null, "interaction_info_type_id": 3, "value_json": {"state": "2"}, "info_status": "active", "return_value": null}, {"interaction_info_id": 233, "interaction_info_name": "TN2012030001", "interaction_info_desp": null, "interaction_info_type_id": 3, "value_json": {"state": "4"}, "info_status": "active", "return_value": null}]} + try { + var data = JsonConvert.DeserializeObject<gzResult<InteractInfoResult>>(result); + if (data.data != null) { + list = data.data; + } + + } + catch (Exception ex) { + Console.WriteLine(ex.Message); + } + + } + else { + msg = "[guozi-QueryInteractInfo]璇诲彇浜や簰淇℃伅澶辫触"; + Console.WriteLine(msg); + } + return list; + } + public static bool UpdateInteractInfo(UpdateInteractInfo interactInfo) { + string msg = ""; + var result = false; + var request = JsonConvert.SerializeObject(interactInfo); + var response = apiHelper.Post(baseUrl + "api/om/interaction_info/update/", request); + msg = $"[mes-UpdateInteractInfo] request={request};response={response}"; + if (response != "") { + var dataResult = JsonConvert.DeserializeObject<gzResult<object>>(response); + result = dataResult.code == 0; + } + else { + msg = "[guozi-UpdateInteractInfo]鏇存柊浜や簰淇℃伅澶辫触"; + Console.WriteLine(msg); + } + return result; + } + + } + + public class gzResult<T> + { + public string app_name { get; set; } + public string version { get; set; } + public int code { get; set; } + public string msg { get; set; } + public List<T> data { get; set; } + } + public class IOState + { + public int io_id { get; set; } + public string io_name { get; set; } + public string io_type_id { get; set; } + public string io_type { get; set; } + public int io_status_id { get; set; } + public string io_status_type { get; set; } + public string parameter_definition_int4_1 { get; set; } + public int io_value_int4_1 { get; set; } + public string parameter_definition_int4_2 { get; set; } + public int io_value_int4_2 { get; set; } + public string parameter_definition_int4_3 { get; set; } + public int io_value_int4_3 { get; set; } + public string parameter_definition_int4_4 { get; set; } + public int io_value_int4_4 { get; set; } + public string parameter_definition_json { get; set; } + public string io_value_json { get; set; } + } + public class IOSateInfo + { + public int io_id { get; set; } + public int io_status_id { get; set; } + public int io_value_int4_1 { get; set; } + public int io_value_int4_2 { get; set; } + public int io_value_int4_3 { get; set; } + public int io_value_int4_4 { get; set; } + public string io_value_json { get; set; } + } + public class IOStatesInfoResult + { + public List<ResultInfo> success_list { get; set; } + public List<ResultInfo> error_list { get; set; } + public class ResultInfo { public int io_id { get; set; } } + } + public class OrderInfo + { + public string order_name { get; set; } + public int priority { get; set; } + public DateTime dead_line { get; set; } + public string ts_name { get; set; } + public string parameters { get; set; }//{\"dock\":1} + public string created_user { get; set; } + + + } + public class OrderInfoResult + { + public int in_order_id { get; set; } + } + public class CancelOrderInfo + { + public List<int> order_list { get; set; } + } + public class CancelOrderInfoResult + { + public List<ResultInfo> success_list { get; set; } + public List<ResultInfo> error_list { get; set; } + public class ResultInfo { public int order_id { get; set; } } + } + public class cancle + { + public List<success_list> success_list { get; set; } + public List<error_list> error_list { get; set; } + } + public class success_list + { + public int order_id { get; set; } + } + + public class error_list + { + } + public class CancelGZOrderResult + { + public string app_name { get; set; } + public string version { get; set; } + public int code { get; set; } + public string msg { get; set; } + public cancle data { get; set; } + public List<int> success_list { get; set; } + public List<int> error_list { get; set; } + } + public class QueryOrderResult + { + public int order_id { get; set; } + public string order_name { get; set; } + public int priority { get; set; } + public DateTime dead_line { get; set; } + public string ts_id { get; set; } + public string parameters { get; set; }//{"TN_LocationName":"3-2-B", "PalletType":1}", + public string trigger { get; set; } + public string command { get; set; } + public string status { get; set; } + public List<int> agv_list { get; set; } + public string current_task { get; set; } + public string current_dest { get; set; } + public string current_opt { get; set; } + public string current_omi { get; set; } + public DateTime create_time { get; set; } + public DateTime? active_time { get; set; } + public DateTime? finished_time { get; set; } + public DateTime? cancel_time { get; set; } + public string response_timespan { get; set; } + public string execute_timespa { get; set; } + public string total_timespan { get; set; } + } + public class InteractInfoResult + { + public int interaction_info_id { get; set; } + public string interaction_info_name { get; set; } + public string interaction_info_desp { get; set; } + public int interaction_info_type_id { get; set; } + public object value_json { get; set; }//{"dock": 1}, + public string info_status { get; set; } + public string return_value { get; set; } + } + public class UpdateInteractInfo + { + public int interaction_info_id { get; set; } + public string info_status { get; set; } + public string return_value { get; set; } + } + public class interaction_state + { + public string state { get; set; } + } + public class interaction_door + { + public string door { get; set; } + } + public class interaction_bit + { + public string order { get; set; } + } +} + diff --git a/dispatch/HanAo.cs b/dispatch/HanAo.cs new file mode 100644 index 0000000..e438738 --- /dev/null +++ b/dispatch/HanAo.cs @@ -0,0 +1,164 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Web.Services.Description; + +namespace HH.WCS.Mobox3.DoubleCoin.dispatch { + /// <summary> + /// 鍥借嚜璋冨害杈呭姪绫�+ /// </summary> + public class HanAo { + private static readonly HttpHelper apiHelper = new HttpHelper(); + private static readonly string baseUrl ="";//閰嶇疆鏂囦欢閲岃幏鍙栧浗鑷皟搴﹀湴鍧�+ //private static readonly string logName = "hanao"; + + + public static bool CreateOrder(TaskInfoModel model) { + var msg = ""; + var result = true; + var request = JsonConvert.SerializeObject(model); + var response = apiHelper.Post(baseUrl + ":9001/wcs-admin/api/receive", request); + msg = $"[hanao-CreateOrder] request={request} response={response}"; + Console.WriteLine(msg); + if (response != "") { + try { + var dataResult = JsonConvert.DeserializeObject<HAResult>(response); + if (dataResult.code == "0") { + result = true; + } + } + catch (Exception ex) { + Console.WriteLine(ex.Message); + } + } + else { + msg = "[hanao-CreateOrder]鍒涘缓璁㈠崟澶辫触"; + Console.WriteLine(msg); + } + + LogHelper.Info(msg,"鏉ゥ"); + return result; + } + public static bool CancelOrder(CancelModel model) { + bool result = false; + string msg = ""; + var request = JsonConvert.SerializeObject(model); + var response = apiHelper.Post(baseUrl + ":9002/wcs-admin/api/cancel", request); + msg = $"[hanao-CancelOrder] request={request};response={response}"; + Console.WriteLine(msg); + if (response != "") { + var dataResult = JsonConvert.DeserializeObject<HAResult>(response); + if (dataResult.code == "0") { + result = true; + } + } + else { + msg = "[hanao-CancelOrder]鍙栨秷璁㈠崟澶辫触"; + Console.WriteLine(msg); + } + LogHelper.Info(msg, "鏉ゥ"); + return result; + } + public static bool QueryDevice(DeviceInfoModel model) { + bool result = false; + string msg = ""; + var request = JsonConvert.SerializeObject(model); + var response = apiHelper.Get(baseUrl + ":9003//wcs-admin/api/dvc-state/", request); + msg = $"[hanao-QueryDeviceResult] request={request};response={response}"; + Console.WriteLine(msg); + if (response != "") { + var dataResult = JsonConvert.DeserializeObject<HAResult>(response); + if (dataResult.code == "0") { + result = true; + } + } + else { + msg = "[hanao-QueryOrderResult]鏌ヨ璁㈠崟淇℃伅澶辫触"; + Console.WriteLine(msg); + } + LogHelper.Info(msg, "鏉ゥ"); + return result; + } + + + public class TaskInfoModel { + /// <summary> + /// 璇锋眰pk + /// </summary> + public string requestPk { get; set; } + /// <summary> + /// 鎵樼洏鏉$爜 + /// </summary> + public string contNo { get; set; } + /// <summary> + /// 鎵樼洏绫诲瀷 + /// </summary> + public string contType { get; set; } = ""; + /// <summary> + /// 浠诲姟绫诲瀷 1-鍏ュ簱 2-鍑哄簱 3-绉诲簱 + /// </summary> + public string trkType { get; set; } + /// <summary> + /// 1-999锛堝�瓒婂ぇ浼樺厛绾ц秺楂橈級 + /// </summary> + public string trkPrty { get; set; } = "1"; + public string frmPos { get; set; } + public string toPos { get; set; } + public string noticeInfo { get; set; } = ""; + /// <summary> + /// 0-绌烘墭鐩�1-瀹炵墿 + /// </summary> + public string isFull { get; set; } = "0"; + public string groupNo { get; set; } = ""; + public string clientCode { get; set; } = "WMS"; + /// <summary> + /// 鏍煎紡锛�022-11-11 11:32:08 + /// </summary> + public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + } + public class HAResult { + public string code { get; set; } + public string msg { get; set; } + /// <summary> + /// + /// </summary> + public string requestPk { get; set; } + } + public class CancelModel { + public string requestPk { get; set; } + public string contNo { get; set; } + public string clientCode { get; set; } + public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + public class DeviceInfoModel { + public string requestPk { get; set; } + public string dvcNo { get; set; } + public string clientCode { get; set; } + public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + public class TaskStateInfoModel { + public string requestPk { get; set; } + public string contNo { get; set; } + /// <summary> + /// 鍙屾柟绯荤粺鍏卞悓瀹氫箟 1-鍏ュ簱 2-鍑哄簱 3-绉诲簱 锛堝悗缁鏈夊鍔犲啀鍗忓畾锛�+ /// </summary> + public string noticeType { get; set; } + public string curPos { get; set; } + public string noticeInfo { get; set; } + /// <summary> + /// 0-鎴愬姛 锛堝叆搴撲笂鏋跺畬鎴�鍑哄簱涓嬫灦瀹屾垚/搴撳唴绉诲簱瀹屾垚锛氱Щ搴撳彧涓婃姤鏈�粓绉诲簱涓婃灦锛�鎴�鍏朵粬-寮傚父鐮�鍙嶉鐩稿叧缁撴灉鍘熷洜锛學MS鏍规嵁鎯呭喌澶勭悊 + /// 1-鍏ュ簱鏈夎揣 2-鍏ヨ繙杩戞湁璐�3-鍑哄簱鏃犺揣 4-鍑鸿繙杩戞湁璐� + /// </summary> + public string code { get; set; } + public string result { get; set; } + public string clientCode { get; set; } + public string reqTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + + } + + +} + diff --git a/dispatch/HostToAGV.cs b/dispatch/HostToAGV.cs new file mode 100644 index 0000000..1583115 --- /dev/null +++ b/dispatch/HostToAGV.cs @@ -0,0 +1,550 @@ +锘�/------------------------------------------------------------------------------ +// <auto-generated> +// 姝や唬鐮佺敱宸ュ叿鐢熸垚銆�+// 杩愯鏃剁増鏈�4.0.30319.42000 +// +// 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋�+// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便� +// </auto-generated> +//------------------------------------------------------------------------------ + +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Web.Services; +using System.Web.Services.Protocols; +using System.Xml.Serialization; + +// +// 姝ゆ簮浠g爜鐢�wsdl 鑷姩鐢熸垚, Version=4.6.1055.0銆�+// + + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +[System.Web.Services.WebServiceBindingAttribute(Name="HostToAGV", Namespace="http://127.0.0.1:9988/HostToAGV.wsdl")] +public class HostToAGV : System.Web.Services.Protocols.SoapHttpClientProtocol { + + private System.Threading.SendOrPostCallback StartNewOrderWithQCmdOperationCompleted; + + private System.Threading.SendOrPostCallback AddNewOrderOperationCompleted; + + private System.Threading.SendOrPostCallback CancelOrderOperationCompleted; + + private System.Threading.SendOrPostCallback ChangeOrderOperationCompleted; + + private System.Threading.SendOrPostCallback QueryOrderOperationCompleted; + + private System.Threading.SendOrPostCallback OrderAddOperationCompleted; + + private System.Threading.SendOrPostCallback OrderChangeParamOperationCompleted; + + /// <remarks/> + public HostToAGV() { + this.Url = "http://127.0.0.1:9988/HostToAGV.cgi"; + } + + /// <remarks/> + public event StartNewOrderWithQCmdCompletedEventHandler StartNewOrderWithQCmdCompleted; + + /// <remarks/> + public event AddNewOrderCompletedEventHandler AddNewOrderCompleted; + + /// <remarks/> + public event CancelOrderCompletedEventHandler CancelOrderCompleted; + + /// <remarks/> + public event ChangeOrderCompletedEventHandler ChangeOrderCompleted; + + /// <remarks/> + public event QueryOrderCompletedEventHandler QueryOrderCompleted; + + /// <remarks/> + public event OrderAddCompletedEventHandler OrderAddCompleted; + + /// <remarks/> + public event OrderChangeParamCompletedEventHandler OrderChangeParamCompleted; + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="urn:HostToAGV", ResponseNamespace="urn:HostToAGV", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute("bufout", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string StartNewOrderWithQCmd([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string bufin) { + object[] results = this.Invoke("StartNewOrderWithQCmd", new object[] { + bufin}); + return ((string)(results[0])); + } + + /// <remarks/> + public System.IAsyncResult BeginStartNewOrderWithQCmd(string bufin, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("StartNewOrderWithQCmd", new object[] { + bufin}, callback, asyncState); + } + + /// <remarks/> + public string EndStartNewOrderWithQCmd(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string)(results[0])); + } + + /// <remarks/> + public void StartNewOrderWithQCmdAsync(string bufin) { + this.StartNewOrderWithQCmdAsync(bufin, null); + } + + /// <remarks/> + public void StartNewOrderWithQCmdAsync(string bufin, object userState) { + if ((this.StartNewOrderWithQCmdOperationCompleted == null)) { + this.StartNewOrderWithQCmdOperationCompleted = new System.Threading.SendOrPostCallback(this.OnStartNewOrderWithQCmdOperationCompleted); + } + this.InvokeAsync("StartNewOrderWithQCmd", new object[] { + bufin}, this.StartNewOrderWithQCmdOperationCompleted, userState); + } + + private void OnStartNewOrderWithQCmdOperationCompleted(object arg) { + if ((this.StartNewOrderWithQCmdCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.StartNewOrderWithQCmdCompleted(this, new StartNewOrderWithQCmdCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="urn:HostToAGV", ResponseNamespace="urn:HostToAGV", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute("bufout", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string AddNewOrder([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string bufin) { + object[] results = this.Invoke("AddNewOrder", new object[] { + bufin}); + return ((string)(results[0])); + } + + /// <remarks/> + public System.IAsyncResult BeginAddNewOrder(string bufin, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("AddNewOrder", new object[] { + bufin}, callback, asyncState); + } + + /// <remarks/> + public string EndAddNewOrder(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string)(results[0])); + } + + /// <remarks/> + public void AddNewOrderAsync(string bufin) { + this.AddNewOrderAsync(bufin, null); + } + + /// <remarks/> + public void AddNewOrderAsync(string bufin, object userState) { + if ((this.AddNewOrderOperationCompleted == null)) { + this.AddNewOrderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddNewOrderOperationCompleted); + } + this.InvokeAsync("AddNewOrder", new object[] { + bufin}, this.AddNewOrderOperationCompleted, userState); + } + + private void OnAddNewOrderOperationCompleted(object arg) { + if ((this.AddNewOrderCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.AddNewOrderCompleted(this, new AddNewOrderCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="urn:HostToAGV", ResponseNamespace="urn:HostToAGV", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute("bufout", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string CancelOrder([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string bufin) { + object[] results = this.Invoke("CancelOrder", new object[] { + bufin}); + return ((string)(results[0])); + } + + /// <remarks/> + public System.IAsyncResult BeginCancelOrder(string bufin, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("CancelOrder", new object[] { + bufin}, callback, asyncState); + } + + /// <remarks/> + public string EndCancelOrder(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string)(results[0])); + } + + /// <remarks/> + public void CancelOrderAsync(string bufin) { + this.CancelOrderAsync(bufin, null); + } + + /// <remarks/> + public void CancelOrderAsync(string bufin, object userState) { + if ((this.CancelOrderOperationCompleted == null)) { + this.CancelOrderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCancelOrderOperationCompleted); + } + this.InvokeAsync("CancelOrder", new object[] { + bufin}, this.CancelOrderOperationCompleted, userState); + } + + private void OnCancelOrderOperationCompleted(object arg) { + if ((this.CancelOrderCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.CancelOrderCompleted(this, new CancelOrderCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="urn:HostToAGV", ResponseNamespace="urn:HostToAGV", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute("bufout", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string ChangeOrder([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string bufin) { + object[] results = this.Invoke("ChangeOrder", new object[] { + bufin}); + return ((string)(results[0])); + } + + /// <remarks/> + public System.IAsyncResult BeginChangeOrder(string bufin, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("ChangeOrder", new object[] { + bufin}, callback, asyncState); + } + + /// <remarks/> + public string EndChangeOrder(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string)(results[0])); + } + + /// <remarks/> + public void ChangeOrderAsync(string bufin) { + this.ChangeOrderAsync(bufin, null); + } + + /// <remarks/> + public void ChangeOrderAsync(string bufin, object userState) { + if ((this.ChangeOrderOperationCompleted == null)) { + this.ChangeOrderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnChangeOrderOperationCompleted); + } + this.InvokeAsync("ChangeOrder", new object[] { + bufin}, this.ChangeOrderOperationCompleted, userState); + } + + private void OnChangeOrderOperationCompleted(object arg) { + if ((this.ChangeOrderCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.ChangeOrderCompleted(this, new ChangeOrderCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="urn:HostToAGV", ResponseNamespace="urn:HostToAGV", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute("bufout", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string QueryOrder([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string bufin) { + object[] results = this.Invoke("QueryOrder", new object[] { + bufin}); + return ((string)(results[0])); + } + + /// <remarks/> + public System.IAsyncResult BeginQueryOrder(string bufin, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("QueryOrder", new object[] { + bufin}, callback, asyncState); + } + + /// <remarks/> + public string EndQueryOrder(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string)(results[0])); + } + + /// <remarks/> + public void QueryOrderAsync(string bufin) { + this.QueryOrderAsync(bufin, null); + } + + /// <remarks/> + public void QueryOrderAsync(string bufin, object userState) { + if ((this.QueryOrderOperationCompleted == null)) { + this.QueryOrderOperationCompleted = new System.Threading.SendOrPostCallback(this.OnQueryOrderOperationCompleted); + } + this.InvokeAsync("QueryOrder", new object[] { + bufin}, this.QueryOrderOperationCompleted, userState); + } + + private void OnQueryOrderOperationCompleted(object arg) { + if ((this.QueryOrderCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.QueryOrderCompleted(this, new QueryOrderCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestElementName="Order-Add", RequestNamespace="urn:HostToAGV", ResponseElementName="Order-AddResponse", ResponseNamespace="urn:HostToAGV", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute("pszResponse", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string OrderAdd([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string pszRequest) { + object[] results = this.Invoke("OrderAdd", new object[] { + pszRequest}); + return ((string)(results[0])); + } + + /// <remarks/> + public System.IAsyncResult BeginOrderAdd(string pszRequest, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("OrderAdd", new object[] { + pszRequest}, callback, asyncState); + } + + /// <remarks/> + public string EndOrderAdd(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string)(results[0])); + } + + /// <remarks/> + public void OrderAddAsync(string pszRequest) { + this.OrderAddAsync(pszRequest, null); + } + + /// <remarks/> + public void OrderAddAsync(string pszRequest, object userState) { + if ((this.OrderAddOperationCompleted == null)) { + this.OrderAddOperationCompleted = new System.Threading.SendOrPostCallback(this.OnOrderAddOperationCompleted); + } + this.InvokeAsync("OrderAdd", new object[] { + pszRequest}, this.OrderAddOperationCompleted, userState); + } + + private void OnOrderAddOperationCompleted(object arg) { + if ((this.OrderAddCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.OrderAddCompleted(this, new OrderAddCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestElementName="Order-ChangeParam", RequestNamespace="urn:HostToAGV", ResponseElementName="Order-ChangeParamResponse", ResponseNamespace="urn:HostToAGV", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + [return: System.Xml.Serialization.XmlElementAttribute("pszResponse", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + public string OrderChangeParam([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)] string pszRequest) { + object[] results = this.Invoke("OrderChangeParam", new object[] { + pszRequest}); + return ((string)(results[0])); + } + + /// <remarks/> + public System.IAsyncResult BeginOrderChangeParam(string pszRequest, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("OrderChangeParam", new object[] { + pszRequest}, callback, asyncState); + } + + /// <remarks/> + public string EndOrderChangeParam(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((string)(results[0])); + } + + /// <remarks/> + public void OrderChangeParamAsync(string pszRequest) { + this.OrderChangeParamAsync(pszRequest, null); + } + + /// <remarks/> + public void OrderChangeParamAsync(string pszRequest, object userState) { + if ((this.OrderChangeParamOperationCompleted == null)) { + this.OrderChangeParamOperationCompleted = new System.Threading.SendOrPostCallback(this.OnOrderChangeParamOperationCompleted); + } + this.InvokeAsync("OrderChangeParam", new object[] { + pszRequest}, this.OrderChangeParamOperationCompleted, userState); + } + + private void OnOrderChangeParamOperationCompleted(object arg) { + if ((this.OrderChangeParamCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.OrderChangeParamCompleted(this, new OrderChangeParamCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + + /// <remarks/> + public new void CancelAsync(object userState) { + base.CancelAsync(userState); + } +} + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +public delegate void StartNewOrderWithQCmdCompletedEventHandler(object sender, StartNewOrderWithQCmdCompletedEventArgs e); + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +public class StartNewOrderWithQCmdCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal StartNewOrderWithQCmdCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public string Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[0])); + } + } +} + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +public delegate void AddNewOrderCompletedEventHandler(object sender, AddNewOrderCompletedEventArgs e); + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +public class AddNewOrderCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal AddNewOrderCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public string Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[0])); + } + } +} + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +public delegate void CancelOrderCompletedEventHandler(object sender, CancelOrderCompletedEventArgs e); + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +public class CancelOrderCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal CancelOrderCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public string Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[0])); + } + } +} + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +public delegate void ChangeOrderCompletedEventHandler(object sender, ChangeOrderCompletedEventArgs e); + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +public class ChangeOrderCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal ChangeOrderCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public string Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[0])); + } + } +} + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +public delegate void QueryOrderCompletedEventHandler(object sender, QueryOrderCompletedEventArgs e); + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +public class QueryOrderCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal QueryOrderCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public string Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[0])); + } + } +} + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +public delegate void OrderAddCompletedEventHandler(object sender, OrderAddCompletedEventArgs e); + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +public class OrderAddCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal OrderAddCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public string Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[0])); + } + } +} + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +public delegate void OrderChangeParamCompletedEventHandler(object sender, OrderChangeParamCompletedEventArgs e); + +/// <remarks/> +[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")] +[System.Diagnostics.DebuggerStepThroughAttribute()] +[System.ComponentModel.DesignerCategoryAttribute("code")] +public class OrderChangeParamCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal OrderChangeParamCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// <remarks/> + public string Result { + get { + this.RaiseExceptionIfNecessary(); + return ((string)(this.results[0])); + } + } +} diff --git a/dispatch/NDC.cs b/dispatch/NDC.cs new file mode 100644 index 0000000..df96703 --- /dev/null +++ b/dispatch/NDC.cs @@ -0,0 +1,164 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace HH.WCS.Mobox3.DoubleCoin.dispatch +{ + public class NDC + { + private static HostToAGV callClient = null; + static NDC() { + callClient = new HostToAGV(); + callClient.Url = Settings.HostToAgvServerUrl; + } + private static string GetReqStrNew(int ts, int pri, string taskNo, Dictionary<string, string> param) { + /*<Req> + <Order TS='5' Pri='80' No='666' NoCallback='0' Ext1='' Ext2='' Ext3=''> + <Param Name='From' Value='10' /> + <Param Name='To' Value='20' /> + <Param Name='Func' Value='1' /> + <Param Name='Data' Value='7' /> + <Param Name='ItemHeight' Value='1' /> + <Param Name='CntrType' Value='12' /> + <Param Name='FromCol' Value='2' /> + <Param Name='ToCol' Value='111' /> + </Order> + </Req>*/ + var sb = new StringBuilder(); + sb.Append($"<Req><Order TS='{ts}' Pri='{pri}' No='{taskNo}'>"); + + foreach (var kv in param) { + sb.Append($"<Param Name='{kv.Key}' Value='{kv.Value}'/>"); + } + sb.Append("</Order></Req>"); + return sb.ToString(); + } + public AGVResult AddNewOrderNew(int ts, int pri, string taskNo, Dictionary<string, string> param) { + //< Req >< Order TS = '1' Pri = '1' No = 'TN2302020001' Ext1 = '' Ext2 = '' N_CNTR_COUNT = '' >< Param Name = 'From' Value = '2' />< Param Name = 'To' Value = '1' /></ Order ></ Req > + + var bufin = GetReqStrNew(ts, pri, taskNo, param); + + try { + + var result = callClient.OrderAdd(bufin); + LogHelper.Info($"浠诲姟涓嬪彂缁撴灉 OrderAdd req={bufin} res={result}", "NDC"); + Console.WriteLine($"浠诲姟涓嬪彂缁撴灉 OrderAdd req={bufin} res={result}"); + //LogHelper.Info(result.bufout, "ts"); + return GetResult(result); + } + catch (Exception e) { + LogHelper.Info($"浠诲姟涓嬪彂澶辫触 OrderAdd req={bufin} res={e.Message}", "NDC"); + //Console.WriteLine($"浠诲姟涓嬪彂澶辫触 AddNewOrder req={bufin} res={e.Message}"); + return new AGVResult { Res = new Res { ErrCode = -1, ErrInfo = e.Message } }; + } + + } + private static string GetReqStr(int ts, Dictionary<string, string> param) { + //< Order TS = '60' Pri = '" + mst.CN_N_PRIORITY.ToString() + "' From = '" + start.CN_N_AGV_TN_Location + "' To = '" + end.CN_N_AGV_TN_Location + "' No = '" + mst.S_CODE + "_1' Ext1 = '1' Ext2 = '" + Constants.TN_MID_COMMANDEQ_CALLAGVOrderCommandType + "' N_CNTR_COUNT = '' FRow = '" + sFloor + "' TRow = '" + eFloor + "' /> + var sb = new StringBuilder(); + sb.Append($"<Req><Order "); + if (ts != 0) { + sb.Append($"TS='{ts}'"); + } + foreach (var kv in param) { + sb.Append($" {kv.Key}='{kv.Value}'"); + } + sb.Append("/></Req>"); + return sb.ToString(); + } + public static AGVResult AddNewOrder(int ts, Dictionary<string, string> param) + { + //< Req >< Order TS = '1' Pri = '1' No = 'TN2302020001' Ext1 = '' Ext2 = '' N_CNTR_COUNT = '' >< Param Name = 'From' Value = '2' />< Param Name = 'To' Value = '1' /></ Order ></ Req > + + var bufin = GetReqStr(ts, param); + + try { + + var result = callClient.AddNewOrder(bufin); + LogHelper.Info($"AddNewOrder req={bufin} res={result}", "NDC"); + return GetResult(result); + } + catch (Exception e) { + LogHelper.Info($"AddNewOrder req={bufin} res={e.Message}", "NDC"); + return new AGVResult { Res = new Res { ErrCode = -1, ErrInfo = e.Message } }; + } + + } + public static AGVResult CancelOrder(int ts, Dictionary<string, string> param) { + //< Req >< Order No = 'TN2302020001' >< Param Name = 'IsForce' Value = '1' /></ Order ></ Req > + var bufin = GetReqStr(ts, param); + try { + var result = callClient.CancelOrder(bufin); + LogHelper.Info($"CancelOrder req={bufin} res={result}", "NDC"); + return GetResult(result); + } + catch (Exception e) { + LogHelper.Info($"CancelOrder req={bufin} res={e.Message}", "NDC"); + return new AGVResult { + Res = new Res { + ErrCode = -1, + ErrInfo = e.Message + } + }; + } + + } + public static AGVResult StartNewOrderWithQCmd(int ts, Dictionary<string, string> param) { + //lpn: <Order TS='41' Pri='' ExtDeviceNo='{0}' CtrlVal='{1}' DispInfo='{2}' No='{3}' Ext1='' Ext2='' N_CNTR_COUNT='' /> + //traccif: <Order TS='164' From='2' To='2' ExtDeviceNo='" + lockNo + "' No='" + DateTime.Now.Ticks.ToString() + "' /> + //lock: <Order TS='170' CtrlVal='" + CtrlVal + "' ExtDeviceNo='" + roadway + "' No='" + DateTime.Now.Ticks.ToString() + "' /> + var bufin = GetReqStr(ts, param); + try { + var r = callClient.StartNewOrderWithQCmd(bufin); + LogHelper.Info($"StartNewOrderWithQCmd req={bufin} res={r}", "NDC"); + return GetResult(r); + } + catch (Exception e) { + LogHelper.Info($"StartNewOrderWithQCmd req={bufin} res={e.Message}", "NDC"); + return new AGVResult { + Res = new Res { + ErrCode = -1, + ErrInfo = e.Message + } + }; + } + } + public static AGVResult ChangeOrder(Dictionary<string, string> param) { + //< Req >< Order No = 'TN2302020002' ParamNo = '18' Param1 = '12' /></ Req > + var bufin = GetReqStr(0, param); + try { + var r = callClient.ChangeOrder(bufin); + LogHelper.Info($"ChangeOrder req={bufin} res={r}", "NDC"); + return GetResult(r); + } + catch (Exception e) { + LogHelper.Info($"ChangeOrder req={bufin} res={e.Message}", "NDC"); + return new AGVResult { + Res = new Res { + ErrCode = -1, + ErrInfo = e.Message + } + }; + } + } + private static AGVResult GetResult(string bufout) { + //<Res><ErrCode>0</ErrCode><Result>11</Result></Res> + XmlDocument xml = new XmlDocument(); + xml.LoadXml(bufout); + var json = JsonConvert.SerializeXmlNode(xml); + return JsonConvert.DeserializeObject<AGVResult>(json); + } + public class AGVResult + { + public Res Res { get; set; } + } + public class Res + { + public int ErrCode { get; set; } + public string ErrInfo { get; set; } + } + } +} diff --git a/dispatch/NDCApi.cs b/dispatch/NDCApi.cs new file mode 100644 index 0000000..50792b1 --- /dev/null +++ b/dispatch/NDCApi.cs @@ -0,0 +1,271 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin; +using HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace HH.WCS.Mobox3.DoubleCoin.dispatch +{ + public class NDCApi + { + public static string NDCApiUrl { set; get; } + static NDCApi() + { + + NDCApiUrl = Settings.NDCApiUrl; + } + + public static AgvApiResult AddOrderNew(int ts, int pri, string taskNo, List<param> param) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + var model = new AddOrderNewModel(); + model.ts_no = ts; + model.pri = pri; + model.task_no = taskNo; + model.param = param; + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{taskNo}涓嬪彂锛寋jsonInfo}", "NDC"); + var result = httpH.WebPost(NDCApiUrl + "Add", jsonInfo); + LogHelper.Info($"浠诲姟涓嬪彂缁撴灉res={result}", "NDC"); + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"浠诲姟涓嬪彂澶辫触 res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + } + + public static AgvApiResult AddOrderNew(AddOrderNewModel model) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{model.task_no}涓嬪彂锛寋jsonInfo}", "NDC"); + + var result = httpH.WebPost(NDCApiUrl + "Add", jsonInfo); + LogHelper.Info($"浠诲姟涓嬪彂缁撴灉res={result}", "NDC"); + + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"浠诲姟涓嬪彂澶辫触 res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + } + + public static AgvApiResult CancelOrder(string tsNo, int is_force = 1) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + var model = new CancelOrderModel(); + model.task_no = tsNo; + model.is_force = is_force; + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{model.task_no}鍙栨秷锛寋jsonInfo}", "NDC"); + + var result = httpH.WebPost(NDCApiUrl + "Cancel", jsonInfo); + LogHelper.Info($"浠诲姟{model.task_no}鍙栨秷缁撴灉={result}", "NDC"); + + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"CancelOrder res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + } + + public static AgvApiResult CancelOrder(CancelOrderModel model) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{model.task_no}鍙栨秷锛寋jsonInfo}", "NDC"); + + var result = httpH.WebPost(NDCApiUrl + "Cancel", jsonInfo); + LogHelper.Info($"浠诲姟{model.task_no}鍙栨秷缁撴灉={result}", "NDC"); + + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"CancelOrder res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + + } + + public static AgvApiResult ChangeOrderPri(string taskNo, int newPri) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + var model = new ChangePriModel(); + model.task_no = taskNo; + model.pri = newPri; + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{model.task_no}浼樺厛绾ф洿鏀癸紝{jsonInfo}", "NDC"); + + var result = httpH.WebPost(NDCApiUrl + "ChangePri", jsonInfo); + LogHelper.Info($"浠诲姟{model.task_no}浼樺厛绾ф洿鏀圭粨鏋�{result}", "NDC"); + + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"ChangeOrderPri res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + } + + public static AgvApiResult ChangeOrderPri(ChangePriModel model) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{model.task_no}浼樺厛绾ф洿鏀癸紝{jsonInfo}", "NDC"); + + var result = httpH.WebPost(NDCApiUrl + "ChangePri", jsonInfo); + LogHelper.Info($"浠诲姟{model.task_no}浼樺厛绾ф洿鏀圭粨鏋�{result}", "NDC"); + + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"ChangeOrderPri res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + } + + public static AgvApiResult ChangeOrderParam(string taskNo, int paramNo, string paramStr) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + var model = new ChangeParamModel(); + model.task_no = taskNo; + model.param_no = paramNo; + model.param = paramStr; + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{model.task_no}鍙傛暟鏇存敼锛寋jsonInfo}", "NDC"); + + var result = httpH.WebPost(NDCApiUrl + "ChangeParam", jsonInfo); + LogHelper.Info($"浠诲姟{model.task_no}鍙傛暟鏇存敼缁撴灉={result}", "NDC"); + + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"ChangeOrderParam res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + } + + public static AgvApiResult ChangeOrderParam(ChangeParamModel model) + { + var httpH = new HttpHelper(); + var agvApiResult = new AgvApiResult(); + try + { + string jsonInfo = JsonConvert.SerializeObject(model); + LogHelper.Info($"浠诲姟{model.task_no}鍙傛暟鏇存敼锛寋jsonInfo}", "NDC"); + + var result = httpH.WebPost(NDCApiUrl + "ChangeParam", jsonInfo); + LogHelper.Info($"浠诲姟{model.task_no}鍙傛暟鏇存敼缁撴灉={result}", "NDC"); + + agvApiResult = JsonConvert.DeserializeObject<AgvApiResult>(result); + return agvApiResult; + } + catch (Exception e) + { + LogHelper.Info($"ChangeOrderParam res={e.Message}", "NDC"); + agvApiResult.err_code = -1; + agvApiResult.err_msg = e.Message; + return agvApiResult; + } + } + } + + /// <summary> + /// 杩斿洖淇℃伅Model + /// </summary> + public class AgvApiResult + { + public int err_code { set; get; }//寮傚父鐮侊細0 - 姝e父锛屽叾瀹冨�涓哄紓甯搁敊璇爜 + public string err_msg { set; get; }//杩斿洖鐨勯敊璇弿杩帮紝鍦�err_code <> 0 鏃惰繑鍥�+ public object result { set; get; }//姝g‘杩斿洖鐨勭粨鏋滃唴瀹癸紝鍦�err_code = 0 涓旀湁杩斿洖鍐呭鏃�+ } + + public class AddOrderNewModel + { + public int ts_no { set; get; }//TS 鍙凤紝蹇呴』鏈夊� + public int pri { set; get; }//浼樺厛绾�+ public string task_no { set; get; }//涓婃父浠诲姟缂栫爜锛屽鏋�no_feedback = 1 鏃讹紝鍙互涓虹┖ + public List<param> param { set; get; } = new List<param>();//鍙傛暟鍒楄〃 + } + + + public class param + { + public string name { set; get; }//鍙傛暟鍚�+ public string value { set; get; }//鍙傛暟鍊�+ } + + public class CancelOrderModel + { + public string task_no { set; get; }//涓婃父浠诲姟缂栫爜 + public int is_force { set; get; } = 1;//鏄惁寮哄埗鍙栨秷锛� 鈥�寮哄埗 + } + + public class ChangeParamModel + { + public string task_no { set; get; }//涓婃父浠诲姟缂栫爜 + public int param_no { set; get; }//鍙傛暟鍙�+ public string param { set; get; }//鍙傛暟鍐呭锛屽涓弬鏁颁互鑻辨枃鍒嗗彿(;)鍒嗛殧 + } + + public class ChangePriModel + { + public string task_no { set; get; }//涓婃父浠诲姟缂栫爜 + public int pri { set; get; }//鏂颁紭鍏堢骇 + } +} diff --git a/dispatch/NDCHelper.cs b/dispatch/NDCHelper.cs new file mode 100644 index 0000000..7aa720f --- /dev/null +++ b/dispatch/NDCHelper.cs @@ -0,0 +1,81 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace HH.WCS.Mobox3.DoubleCoin.dispatch +{ + public class NDCHelper + { + public static void Test() { + //dic.Add("Ext1", ""); dic.Add("Ext2", ""); dic.Add("N_CNTR_COUNT", ""); + //var r = callClient.AddNewOrderAsync(new AddNewOrderRequest() { bufin = "<Req><Order Pri='1' TS='1' From='1' To='2' No='123471118_1' Ext1='1' Ext2='CALLADDAGV' N_CNTR_COUNT='' /></Req>" }); + //r.Wait(); + + var dic = new Dictionary<string, string>(); + dic.Add("Pri", "1"); dic.Add("From", "1"); dic.Add("To", "1"); dic.Add("No", "12311411718_2");// dic.Add("Ext1", "1"); dic.Add("Ext2", "CALLADDAGV"); dic.Add("N_CNTR_COUNT", ""); + var result = NDC.AddNewOrder(1, dic); + + var dic1 = new Dictionary<string, string>(); + var no = "3454566666"; + dic1.Add("From", "1"); dic1.Add("To", "0"); dic1.Add("No", no); + result = NDC.AddNewOrder(101, dic1); + + var dic2 = new Dictionary<string, string>(); + dic2.Add("ExtDeviceNo", "1"); dic2.Add("From", "2"); dic2.Add("To", "2"); dic2.Add("No", DateTime.Now.Ticks.ToString()); dic2.Add("CtrlVal", "1"); + result = NDC.AddNewOrder(39, dic2); + + var dic3 = new Dictionary<string, string>(); + dic3.Add("From", "1"); dic3.Add("To", "9"); dic3.Add("No", no); + result = NDC.CancelOrder(101, dic3); + + var dic4 = new Dictionary<string, string>(); + dic4.Add("ExtDeviceNo", "1"); dic4.Add("CtrlVal", "1"); dic4.Add("DispInfo", "AAAAAAAA"); dic4.Add("No", DateTime.Now.Ticks.ToString()); + result = NDC.StartNewOrderWithQCmd(41, dic4); + + var dic5 = new Dictionary<string, string>(); + dic5.Add("ExtDeviceNo", "1"); dic5.Add("CtrlVal", "1"); dic5.Add("No", DateTime.Now.Ticks.ToString()); + result = NDC.StartNewOrderWithQCmd(170, dic5); + + var dic6 = new Dictionary<string, string>(); + dic6.Add("ExtDeviceNo", "11"); dic6.Add("From", "2"); dic6.Add("To", "2"); dic6.Add("No", DateTime.Now.Ticks.ToString()); + result = NDC.StartNewOrderWithQCmd(164, dic6); + + var dic7 = new Dictionary<string, string>(); + dic7.Add("Param1", "50"); dic7.Add("No", DateTime.Now.Ticks.ToString()); + result = NDC.ChangeOrder(dic7); + } + + public static bool ChangeParam(string taskNo, int param1, int paramNo = 0) { + bool bResult = false; + var dic = new Dictionary<string, string>(); + dic.Add("No", taskNo); + if (paramNo >= 0) { + dic.Add("ParamNo", paramNo.ToString()); + } + dic.Add("Param1", param1.ToString()); + var result = NDC.ChangeOrder(dic); + return bResult; + } + + public static bool Traffic(string lockNo) { + bool bResult = false; + var dic = new Dictionary<string, string>(); + dic.Add("ExtDeviceNo", lockNo); + dic.Add("From", "2"); + dic.Add("To", "2"); dic.Add("No", DateTime.Now.Ticks.ToString()); + + var result = NDC.StartNewOrderWithQCmd(164, dic); + return bResult; + } + + public static bool Cancel(string taskNo) { + bool bResult = false; + var dic = new Dictionary<string, string>(); + dic.Add("No", taskNo); + dic.Add("IsForce", "1"); + + var result = NDC.CancelOrder(1, dic); + return bResult; + } + } +} diff --git a/models/BaseModel.cs b/models/BaseModel.cs new file mode 100644 index 0000000..c6cca53 --- /dev/null +++ b/models/BaseModel.cs @@ -0,0 +1,25 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + public class BaseModel + { + [SugarColumn(IsPrimaryKey = true)] + public string S_ID { get; set; } = Guid.NewGuid().ToString("D"); + public string S_CREATOR_ID { get; set; } = "sa"; + public string S_CREATOR_NAME { get; set; } = "瓒呯骇鐢ㄦ埛"; + public DateTime T_CREATE { get; set; } = DateTime.Now; + public DateTime T_MODIFY { get; set; } = DateTime.Now; + + /// <summary> + /// 缂栬緫銆佸畾鐗�+ /// </summary> + public string S_STATE { get; set; } = "缂栬緫"; + //public string G_SOURCE_OBJ { get; set; } + } +} diff --git a/models/TN_CAR_IN.cs b/models/TN_CAR_IN.cs new file mode 100644 index 0000000..7301cdb --- /dev/null +++ b/models/TN_CAR_IN.cs @@ -0,0 +1,20 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 瀹瑰櫒鐢熶骇杞︽暟鍏宠仈瀛愯〃 + /// </summary> + [SugarTable("TN_CAR_IN")] + public class TN_CAR_IN : BaseModel + { + public string S_CNTR_CODE { set; get; }//瀹瑰櫒鍙�+ public string S_CAR_CODE { set; get; }//鐢熶骇杞︽暟锛岄�鍙峰垎鍓�+ public string S_B_STATE { set; get; }//鐘舵� + } +} diff --git a/models/TN_CG_Detail.cs b/models/TN_CG_Detail.cs new file mode 100644 index 0000000..3ef15ed --- /dev/null +++ b/models/TN_CG_Detail.cs @@ -0,0 +1,47 @@ +using HH.WCS.Mobox3.DoubleCoin.models; +using SqlSugar; +using System; + +namespace HH.WCS.Mobox3.DoubleCoin +{ + + //CntrItemRel + [SugarTable("TN_CG_Detail")] + public class TN_CG_Detail : BaseModel + { + /// <summary> + /// 货品ID + /// </summary> + public string S_CG_ID { get; set; } + + public string S_CAR_CODE { get; set; }//车号 + + public string S_CNTR_CODE { get; set; }//容器编码 + + //public string C_ITEM_MERGE { get; set; }//相同ITEM合并 + + public string S_ITEM_CODE { get; set; }//货品编码 + + public string S_ITEM_SPEC { get; set; }//货品规格 + + public string S_SPE { get; set; }//货品规格 + + /// <summary> + /// 0合格1待检2不合格,下线即待检,3过期 + /// </summary> + public string S_ITEM_STATE { get; set; }//货品状态 + + /// <summary> + /// 0合格1待检2不合格,下线即待检,3过期 + /// </summary> + public int N_ITEM_STATE { get; set; }//货品状态_字典 + public string S_BATCH_NO { get; set; }//批次号 + + public float F_QTY { get; set; }//数量 + + /// <summary> + /// 拆盘时的唯一键,用于追踪被拆的物料 + /// </summary> + public string S_Separate_ID { get; set; } + } +} diff --git a/models/TN_Component_Detail.cs b/models/TN_Component_Detail.cs new file mode 100644 index 0000000..01d8a14 --- /dev/null +++ b/models/TN_Component_Detail.cs @@ -0,0 +1,78 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 閮ㄤ欢鐢ㄦ枡鏄庣粏 + /// </summary> + [SugarTable("TN_Component_Detail")] + public class TN_Component_Detail : BaseModel + { + /// <summary> + /// 鍑哄簱鏃堕棿 + /// </summary> + public DateTime OutAreaTime { get; set; } + + /// <summary> + /// 鐝 + /// </summary> + public string Shift { get; set; } + + /// <summary> + /// 鐗╂枡缂栫爜 + /// </summary> + public string ItemCode { get; set; } + + /// <summary> + /// 鐗╂枡瑙勬牸 + /// </summary> + public string Spec { get; set; } + + /// <summary> + /// 杞︽ + /// </summary> + public string CarCode { get; set; } + + /// <summary> + /// 缁堢偣 + /// </summary> + public string EndLoc { get; set; } + + /// <summary> + /// 鎿嶄綔浜哄憳濮撳悕 + /// </summary> + public string Staff { get; set; } + + /// <summary> + /// 瀹瑰櫒缂栫爜 + /// </summary> + public string CntrCode { get; set; } + + /// <summary> + /// 閲嶉噺 + /// </summary> + public float Weight { get; set; } + + /// <summary> + /// 浠诲姟绫诲瀷 + /// </summary> + public string Type { get; set; } + + /// <summary> + /// 浠诲姟鍙�+ /// </summary> + public string TaskNo { get; set; } + + /// <summary> + /// 閫佽揪鏃堕棿 + /// </summary> + public DateTime EndTime { get; set; } + + + } +} diff --git a/models/TN_Container.cs b/models/TN_Container.cs new file mode 100644 index 0000000..302902f --- /dev/null +++ b/models/TN_Container.cs @@ -0,0 +1,13 @@ +using HH.WCS.Mobox3.DoubleCoin.models; +using SqlSugar; +using System; +using System.Collections.Generic; + +namespace HH.WCS.Mobox3.DoubleCoin { + [SugarTable("TN_Container")] + public class TN_Container : BaseModel { + public string S_CODE { get; set; } + + public int N_DETAIL_COUNT { get; set; } + } +} diff --git a/models/TN_DayProDetail.cs b/models/TN_DayProDetail.cs new file mode 100644 index 0000000..fd80274 --- /dev/null +++ b/models/TN_DayProDetail.cs @@ -0,0 +1,27 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 姣忔棩浜ч噺鍚堣 + /// </summary> + [SugarTable("TN_DayProDetail")] + public class TN_DayProDetail : BaseModel + { + /// <summary> + /// 褰撳ぉ闆剁偣 + /// </summary> + public DateTime DayTime { get; set; } + + /// <summary> + /// 鎬婚噸閲�+ /// </summary> + public float Weight { get; set; } + + } +} diff --git a/models/TN_EquipProDetail.cs b/models/TN_EquipProDetail.cs new file mode 100644 index 0000000..0b17682 --- /dev/null +++ b/models/TN_EquipProDetail.cs @@ -0,0 +1,76 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 璁惧鐢熶骇鏄庣粏 + /// </summary> + [SugarTable("TN_EquipProDetail")] + public class TN_EquipProDetail : BaseModel + { + /// <summary> + /// 浠诲姟绫诲瀷 + /// </summary> + public string TaskType { get; set; } + + /// <summary> + /// 涓嬬嚎鏃堕棿 + /// </summary> + public DateTime DownLineTime { get; set; } = DateTime.Now; + + /// <summary> + /// 瀹瑰櫒鍙�+ /// </summary> + public string RFID { get; set; } + + /// <summary> + /// 鐧诲綍濮撳悕 + /// </summary> + public string LoginName { get; set; } + + /// <summary> + /// 鐝 + /// </summary> + public string Shift { get; set; } + + /// <summary> + /// 鐗╂枡缂栫爜 + /// </summary> + public string ItemCode { get; set; } + + /// <summary> + /// 瑙勬牸 + /// </summary> + public string Spec { get; set; } + + /// <summary> + /// 杞﹀彿 + /// </summary> + public string CarCode { get; set; } + + /// <summary> + /// 閲嶉噺 + /// </summary> + public float Weight { get; set; } + + /// <summary> + /// 鐗╂枡鐘舵� + /// </summary> + public string ItemState { get; set; } + + /// <summary> + /// 璧风偣璐т綅 + /// </summary> + public string StartLoc { get; set; } + + /// <summary> + /// 杩囨湡鏃堕棿 + /// </summary> + public DateTime Expiration { get; set; } + } +} diff --git a/models/TN_InventoryM.cs b/models/TN_InventoryM.cs new file mode 100644 index 0000000..a6f7da3 --- /dev/null +++ b/models/TN_InventoryM.cs @@ -0,0 +1,61 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// WMS搴撳瓨绠$悊 + /// </summary> + [SugarTable("TN_InventoryM")] + public class TN_InventoryM : BaseModel + { + /// <summary> + /// 鍏ュ簱鏃堕棿 + /// </summary> + public DateTime InAreaTime { get; set; } + + /// <summary> + /// 瀹瑰櫒鍙�+ /// </summary> + public string RFID { get; set; } + + /// <summary> + /// 鐧诲綍濮撳悕 + /// </summary> + public string LoginName { get; set; } + + /// <summary> + /// 鐝 + /// </summary> + public string Shift { get; set; } + + /// <summary> + /// 鐗╂枡缂栫爜 + /// </summary> + public string ItemCode { get; set; } + + /// <summary> + /// 瑙勬牸 + /// </summary> + public string Spec { get; set; } + + /// <summary> + /// 閲嶉噺 + /// </summary> + public float Weight { get; set; } + + /// <summary> + /// 鐗╂枡鐘舵� + /// </summary> + public string ItemState { get; set; } + + /// <summary> + /// 杩囨湡鏃堕棿 + /// </summary> + public DateTime Expiration { get; set; } + } +} diff --git a/models/TN_Loc_Container.cs b/models/TN_Loc_Container.cs new file mode 100644 index 0000000..3ba0124 --- /dev/null +++ b/models/TN_Loc_Container.cs @@ -0,0 +1,23 @@ +using HH.WCS.Mobox3.DoubleCoin.models; +using SqlSugar; +using System; +using System.Collections.Generic; + +namespace HH.WCS.Mobox3.DoubleCoin +{ + //TN_Loc_Container + //LocCntrRel + [SugarTable("TN_Loc_Container")] + public class TN_Loc_Container : BaseModel + { + //[SugarColumn(IsPrimaryKey = true)]//父类已有主键,重复设置会导航查不到 + public string S_LOC_CODE { get; set; } + public string S_CNTR_CODE { get; set; } + + [Navigate(NavigateType.OneToMany, nameof(TN_CG_Detail.S_CNTR_CODE))] + public List<TN_CG_Detail> CntrItemRels { get; set; } + + [Navigate(NavigateType.OneToOne, nameof(S_CNTR_CODE))] + public TN_Container Container { get; set; } + } +} diff --git a/models/TN_Location.cs b/models/TN_Location.cs new file mode 100644 index 0000000..fe55430 --- /dev/null +++ b/models/TN_Location.cs @@ -0,0 +1,60 @@ +using HH.WCS.Mobox3.DoubleCoin.models; +using SqlSugar; +using System; +using System.Collections.Generic; + +namespace HH.WCS.Mobox3.DoubleCoin { + + [SugarTable("TN_Location")] + public class TN_Location : BaseModel { + + + //[SugarColumn(IsPrimaryKey = true)] + public string S_CODE { get; set; } + public string S_NAME { get; set; } + public string S_AREA_CODE { get; set; } + public int N_CAPACITY { get; set; } + /// <summary> + /// 鍥借嚜搴撲綅鍚嶇О + /// </summary> + public string S_AGV_SITE { get; set; } + public int N_CURRENT_NUM { get; set; } + + public int N_LAYER { get; set; } + + + /// <summary> + /// 0鏃�1鍏ュ簱閿�2鍑哄簱閿�3鍏跺畠閿�+ /// </summary> + public string S_LOCK_STATE { get; set; } + + /// <summary> + /// 0鏃�1鍏ュ簱閿�2鍑哄簱閿�3鍏跺畠閿�+ /// </summary> + public int N_LOCK_STATE { get; set; } + + public string C_ENABLE { get; set; } + + public string S_LOCK_OP { get; set; } + + public string S_AGV_SITE2 { get; set; } + public string S_AGV_SITE3 { get; set; } + public string S_AGV_SITE4 { get; set; } + public string S_AGV_SITE5 { get; set; } + + + [Navigate(NavigateType.OneToMany, nameof(TN_Loc_Container.S_LOC_CODE))] + public List<TN_Loc_Container> LocCntrRels { get; set; } + + internal static string GetLockStateStr(int lockState) { + var str = ""; + switch (lockState) { + case 0: str = "鏃�; break; + case 1: str = "鍏ュ簱閿�; break; + case 2: str = "鍑哄簱閿�; break; + case 3: str = "鍏跺畠閿�; break; + } + return str; + } + } +} diff --git a/models/TN_MonthProDetail.cs b/models/TN_MonthProDetail.cs new file mode 100644 index 0000000..d3254a9 --- /dev/null +++ b/models/TN_MonthProDetail.cs @@ -0,0 +1,27 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 姣忔湀浜ч噺鍚堣 + /// </summary> + [SugarTable("TN_MonthProDetail")] + public class TN_MonthProDetail : BaseModel + { + /// <summary> + /// 姣忔湀1鍙烽浂鐐�+ /// </summary> + public DateTime DayTime { get; set; } + + /// <summary> + /// 鎬婚噸閲�+ /// </summary> + public float Weight { get; set; } + + } +} diff --git a/models/TN_Operator_info.cs b/models/TN_Operator_info.cs new file mode 100644 index 0000000..253b60b --- /dev/null +++ b/models/TN_Operator_info.cs @@ -0,0 +1,36 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// PDA鎿嶄綔浜哄憳淇℃伅 + /// </summary> + [SugarTable("TN_Operator_Info")] + public class TN_Operator_Info : BaseModel + { + /// <summary> + /// 鎿嶄綔浜哄憳 + /// </summary> + public string S_STAFF { get; set; } + + /// <summary> + /// 瀹瑰櫒缂栫爜 + /// </summary> + public string S_SNTR_CODE { get; set; } + + /// <summary> + /// 閲嶉噺 + /// </summary> + public int F_QTY { get; set; } + + /// <summary> + /// 浠诲姟绫诲瀷 + /// </summary> + public string S_TYPE { get; set; } + } +} diff --git a/models/TN_RemeltDetail.cs b/models/TN_RemeltDetail.cs new file mode 100644 index 0000000..3d3f4fe --- /dev/null +++ b/models/TN_RemeltDetail.cs @@ -0,0 +1,71 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 鍥炵倝鏂欐槑缁�+ /// </summary> + [SugarTable("TN_RemeltDetail")] + public class TN_RemeltDetail:BaseModel + { + /// <summary> + /// 鍥炵倝鏃堕棿 + /// </summary> + public DateTime RemeltTime { set; get;} + + /// <summary> + /// 鎵樼洏鍙�+ /// </summary> + public string CntCode { set; get;} + + /// <summary> + /// 鎿嶄綔浜哄鍚�+ /// </summary> + public string LoginName { set; get;} + + /// <summary> + /// 鐝 + /// </summary> + public string Shift { set; get;} + + /// <summary> + /// 鐗╂枡缂栫爜 + /// </summary> + public string ItemCode { set; get;} + + /// <summary> + /// 鐗╂枡瑙勬牸 + /// </summary> + public string Spec { set; get;} + + /// <summary> + /// 杞︽ + /// </summary> + public string CarCode { set; get;} + + /// <summary> + /// 閲嶉噺 + /// </summary> + public float Weight { set; get;} + + /// <summary> + /// 鍥炵倝鏈哄彴 + /// </summary> + public string StartLoc { set; get;} + + /// <summary> + /// 閫佽揪鏃堕棿 + /// </summary> + public DateTime EndTime { set; get;} + + /// <summary> + /// 浠诲姟鍙�+ /// </summary> + public string TaskNo { set; get; } + } +} diff --git a/models/TN_SPOT_CHECK.cs b/models/TN_SPOT_CHECK.cs new file mode 100644 index 0000000..e2b1e7e --- /dev/null +++ b/models/TN_SPOT_CHECK.cs @@ -0,0 +1,58 @@ +锘縰sing HH.WCS.Mobox3.YueLi.models; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.YueLiYueLi.models +{ + /// <summary> + /// 鎶芥鍗�+ /// </summary> + [SugarTable("TN_SPOT_CHECK")] + public class TN_SPOT_CHECK : BaseModel + { + /// <summary> + /// 鎶芥鍗曞彿 + /// </summary> + public string S_NO { get; set; } + + + /// <summary> + /// 浠撳簱缂栧彿 + /// </summary> + public string S_WH_CODE { get; set; } + + /// <summary> + /// 搴撳尯缂栫爜 + /// </summary> + public string S_AREA_CODE { get; set; } + + /// <summary> + /// 涓氬姟鐘舵� + /// </summary> + public int N_B_STATE { get; set; } + + /// <summary> + /// 鍞竴鐮�+ /// </summary> + public string GRN { get; set; } + + /// <summary> + /// 鐗瑰緛鐮�+ /// </summary> + public string FEATURECODE { get; set; } + + /// <summary> + /// 缁堢偣搴撳尯 + /// </summary> + public string ENDLOC { get; set; } + + /// <summary> + /// 鍒涘缓鏃堕棿 + /// </summary> + public string CREATETIME { get; set; } + } +} diff --git a/models/TN_SPOT_DATEIL.cs b/models/TN_SPOT_DATEIL.cs new file mode 100644 index 0000000..ea1cd32 --- /dev/null +++ b/models/TN_SPOT_DATEIL.cs @@ -0,0 +1,42 @@ +锘縰sing HH.WCS.Mobox3.YueLi.models; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.YueLiYueLi.models +{ + /// <summary> + /// 鎶芥鍗曟槑缁嗭紙璺烼N_CG_Detail鍒楀熀鏈竴鏍凤級 + /// </summary> + [SugarTable("TN_SPOT_DATEIL")] + public class TN_SPOT_DATEIL : BaseModel + { + /// <summary> + /// 瀹瑰櫒缂栫爜 + /// </summary> + public string S_CNTR_CODE { get; set; } + + /// <summary> + /// 涓氬姟鐘舵� + /// </summary> + public int N_B_STATE { get; set; } + + /// <summary> + /// 鎶芥鍗曞彿 + /// </summary> + public string S_BS_NO { get; set; } + + /// <summary> + /// 缁堢偣搴撳尯 + /// </summary> + public string END_LOC { get; set; } + + /// <summary> + /// 鏈堢珛鍞竴鐮�+ /// </summary> + public string GRN { get; set; } + } +} diff --git a/models/TN_SurplusDetail.cs b/models/TN_SurplusDetail.cs new file mode 100644 index 0000000..340f68c --- /dev/null +++ b/models/TN_SurplusDetail.cs @@ -0,0 +1,71 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 浣欐枡鍥炲簱鏄庣粏 + /// </summary> + [SugarTable("TN_SurplusDetail")] + public class TN_SurplusDetail : BaseModel + { + /// <summary> + /// 鍥炲簱鏃堕棿 + /// </summary> + public DateTime RemeltTime { set; get; } + + /// <summary> + /// 鎵樼洏鍙�+ /// </summary> + public string CntCode { set; get; } + + /// <summary> + /// 鎿嶄綔浜哄鍚�+ /// </summary> + public string LoginName { set; get; } + + /// <summary> + /// 鐝 + /// </summary> + public string Shift { set; get; } + + /// <summary> + /// 鐗╂枡缂栫爜 + /// </summary> + public string ItemCode { set; get; } + + /// <summary> + /// 鐗╂枡瑙勬牸 + /// </summary> + public string Spec { set; get; } + + /// <summary> + /// 杞︽ + /// </summary> + public string CarCode { set; get; } + + /// <summary> + /// 浜屾绉伴噸閲嶉噺 + /// </summary> + public float Weight { set; get; } + + /// <summary> + /// 杩斿洖鏈哄彴 + /// </summary> + public string StartLoc { set; get; } + + /// <summary> + /// 浜屾鍏ュ簱鏃堕棿 + /// </summary> + public DateTime EndTime { set; get; } + + /// <summary> + /// 浠诲姟鍙�+ /// </summary> + public string TaskNo { set; get; } + } +} diff --git a/models/TN_TN_SPE.cs b/models/TN_TN_SPE.cs new file mode 100644 index 0000000..1fde398 --- /dev/null +++ b/models/TN_TN_SPE.cs @@ -0,0 +1,31 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 瑙勬牸鏃堕棿閰嶇疆琛�+ /// </summary> + [SugarTable("TN_TN_SPE")] + public class TN_TN_SPE : BaseModel + { + /// <summary> + /// 瑙勬牸 + /// </summary> + public string S_SPE { get; set; } + + /// <summary> + /// 杩囨湡鏃堕棿 + /// </summary> + public int? N_EXPIRE_TIME { get; set; } + + /// <summary> + /// 闈欑疆鏃堕棿 + /// </summary> + public int? N_STANDING_TIME { get; set; } + } +} diff --git a/models/TN_Task.cs b/models/TN_Task.cs new file mode 100644 index 0000000..54a9b2e --- /dev/null +++ b/models/TN_Task.cs @@ -0,0 +1,60 @@ +using HH.WCS.Mobox3.DoubleCoin.models; +using SqlSugar; +using System; + +namespace HH.WCS.Mobox3.DoubleCoin { + [SugarTable("TN_Task")] + public class TN_Task : BaseModel { + + + public string S_START_AREA { get; set; } + public string S_END_AREA { get; set; } + public string S_START_LOC { get; set; } + public string S_END_LOC { get; set; } + + public DateTime? T_START_TIME { get; set; } + public DateTime? T_END_TIME { get; set; } + public string S_EQ_NO { get; set; } + public string S_TYPE { get; set; } + public string S_B_STATE { get; set; } = "绛夊緟"; + /// <summary> + /// 0绛夊緟 1宸叉帹閫� 2鎵ц 3瀹屾垚 4閿欒 + /// </summary> + public int N_B_STATE { get; set; } + + + /// <summary> + ///0鏃�1NDC 2澶╃洰 3鍥借嚜 4PLC 5鏉ゥ + /// </summary> + public int N_SCHEDULE_TYPE { get; set; }=1; + + public int N_PRIORITY { get; set; } = 3; + + public string S_CODE { get; set; } + + public string S_EQ_TASK_CODE { get; set; } + + + public string S_CNTR_CODE { get; set; } + public string S_OP_NAME { get; set; } + + public int N_START_LAYER { get; set; } + public int N_END_LAYER { get; set; } + public int N_CNTR_COUNT { get; set; } + + public string S_SPEC { get; set; } + + internal static string GetStateStr(int state) { + //0绛夊緟 1宸叉帹閫� 2鎵ц 3瀹屾垚 4閿欒 + var status = ""; + switch (state) { + case 0: status = "绛夊緟"; break; + case 1: status = "宸叉帹閫�; break; + case 2: status = "鎵ц"; break; + case 3: status = "瀹屾垚"; break; + case 4: status = "閿欒"; break; + } + return status; + } + } +} diff --git a/models/TN_Task_Action.cs b/models/TN_Task_Action.cs new file mode 100644 index 0000000..5068771 --- /dev/null +++ b/models/TN_Task_Action.cs @@ -0,0 +1,19 @@ +using HH.WCS.Mobox3.DoubleCoin.models; +using SqlSugar; +using System; + +namespace HH.WCS.Mobox3.DoubleCoin +{ + [SugarTable("TN_Task_Action")] + public class TN_Task_Action : BaseModel + { + public string S_EQ_TYPE { get; set; } + public string S_DATA { get; set; } + + public string S_TASK_CODE { get; set; } + public string S_EQ_CODE { get; set; } + + + public int N_ACTION_CODE { get; set; } + } +} diff --git a/models/TN_WeekProDetail.cs b/models/TN_WeekProDetail.cs new file mode 100644 index 0000000..d3ac94b --- /dev/null +++ b/models/TN_WeekProDetail.cs @@ -0,0 +1,27 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 姣忓懆浜ч噺鍚堣 + /// </summary> + [SugarTable("TN_WeekProDetail")] + public class TN_WeekProDetail : BaseModel + { + /// <summary> + /// 鍛ㄤ竴闆剁偣 + /// </summary> + public DateTime DayTime { get; set; } + + /// <summary> + /// 鎬婚噸閲�+ /// </summary> + public float Weight { get; set; } + + } +} diff --git a/models/TN_WorkOrder.cs b/models/TN_WorkOrder.cs new file mode 100644 index 0000000..a10c8cc --- /dev/null +++ b/models/TN_WorkOrder.cs @@ -0,0 +1,20 @@ +using HH.WCS.Mobox3.DoubleCoin.models; +using SqlSugar; +using System; + +namespace HH.WCS.Mobox3.DoubleCoin +{ + /// <summary> + /// 生产工单 + /// </summary> + [SugarTable("TN_WorkOrder")] + public class TN_WorkOrder : BaseModel + { + public string S_WORK_NO { get; set; }//工单号,主键 + public string S_B_STATE { get; set; }//工单状态,新建-开启-暂停-完成 + public string S_ITEM_CODE { get; set; }//物料编码 + public string S_BATCH_CODE { get; set; }//批次号 + public string S_ITEM_SPEC { get; set; }//规格 + public string S_LINE_NO { get; set; }//产线,不能为null + } +} diff --git a/models/TN_YearProDetail.cs b/models/TN_YearProDetail.cs new file mode 100644 index 0000000..1b6c051 --- /dev/null +++ b/models/TN_YearProDetail.cs @@ -0,0 +1,27 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.models +{ + /// <summary> + /// 姣忓勾浜ч噺鍚堣 + /// </summary> + [SugarTable("TN_YearProDetail")] + public class TN_YearProDetail : BaseModel + { + /// <summary> + /// 姣忓勾1鏈�鍙烽浂鐐�+ /// </summary> + public DateTime DayTime { get; set; } + + /// <summary> + /// 鎬婚噸閲�+ /// </summary> + public float Weight { get; set; } + + } +} diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..17b206b --- /dev/null +++ b/packages.config @@ -0,0 +1,53 @@ +锘�?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="BouncyCastle.Cryptography" version="2.4.0" targetFramework="net462" /> + <package id="EasyModbusTCP" version="5.6.0" targetFramework="net461" /> + <package id="Microsoft.AspNet.WebApi.Client" version="6.0.0" targetFramework="net462" /> + <package id="Microsoft.AspNet.WebApi.Core" version="5.3.0" targetFramework="net462" /> + <package id="Microsoft.AspNet.WebApi.Owin" version="5.3.0" targetFramework="net462" /> + <package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.3.0" targetFramework="net462" /> + <package id="Microsoft.AspNet.WebApi.WebHost" version="5.3.0" targetFramework="net462" /> + <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" /> + <package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net462" /> + <package id="Microsoft.Extensions.Logging.Abstractions" version="3.1.32" targetFramework="net462" /> + <package id="Microsoft.Owin" version="4.2.2" targetFramework="net461" /> + <package id="Microsoft.Owin.Host.HttpListener" version="4.2.2" targetFramework="net461" /> + <package id="Microsoft.Owin.Hosting" version="4.2.2" targetFramework="net461" /> + <package id="Microsoft.Web.Infrastructure" version="2.0.0" targetFramework="net462" /> + <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" /> + <package id="Newtonsoft.Json.Bson" version="1.0.2" targetFramework="net462" /> + <package id="NLog" version="5.3.4" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua" version="1.5.374.126" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua.Client" version="1.5.374.126" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua.Configuration" version="1.5.374.126" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua.Core" version="1.5.374.126" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua.Gds.Client.Common" version="1.5.374.126" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua.Gds.Server.Common" version="1.5.374.126" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua.Security.Certificates" version="1.5.374.126" targetFramework="net462" /> + <package id="OPCFoundation.NetStandard.Opc.Ua.Server" version="1.5.374.126" targetFramework="net462" /> + <package id="Owin" version="1.0" targetFramework="net461" /> + <package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net462" /> + <package id="S7netplus" version="0.20.0" targetFramework="net461" requireReinstallation="true" /> + <package id="SqlSugar" version="5.1.4.169" targetFramework="net462" /> + <package id="Swashbuckle" version="5.6.0" targetFramework="net461" /> + <package id="Swashbuckle.Core" version="5.6.0" targetFramework="net461" /> + <package id="System.Buffers" version="4.5.1" targetFramework="net461" /> + <package id="System.Diagnostics.DiagnosticSource" version="6.0.1" targetFramework="net462" /> + <package id="System.Formats.Asn1" version="8.0.1" targetFramework="net462" /> + <package id="System.Memory" version="4.5.5" targetFramework="net461" /> + <package id="System.Net.Http" version="4.3.4" targetFramework="net462" /> + <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" /> + <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net461" /> + <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net452" /> + <package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net462" /> + <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net462" /> + <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net462" /> + <package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net462" /> + <package id="System.ServiceModel.Primitives" version="4.10.0" targetFramework="net462" /> + <package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net48" /> + <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net461" /> + <package id="System.ValueTuple" version="4.5.0" targetFramework="net48" requireReinstallation="true" /> + <package id="Topshelf" version="4.3.0" targetFramework="net452" /> + <package id="Topshelf.NLog" version="4.3.0" targetFramework="net452" /> + <package id="WebActivatorEx" version="2.2.0" targetFramework="net462" /> +</packages> \ No newline at end of file diff --git a/process/DeviceProcess.cs b/process/DeviceProcess.cs new file mode 100644 index 0000000..c75e483 --- /dev/null +++ b/process/DeviceProcess.cs @@ -0,0 +1,62 @@ +锘縰sing HH.WCS.JunzhouNongfu.device; +using HH.WCS.Mobox3.DoubleCoin.device; +using HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.util; +using HH.WCS.Mobox3.DoubleCoin.wms; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +namespace HH.WCS.Mobox3.DoubleCoin.process +{ + /// <summary> + /// 璁惧淇″彿澶勭悊锛屼富瑕佹槸tcp淇″彿锛屾垜浠仛server琚姩鎺ユ敹淇″彿鏉ュ鐞嗭紝鏍规嵁椤圭洰瀹氬埗鐨�+ /// </summary> + internal class DeviceProcess + { + internal static void Analysis(string data, string ip) { + if (data.Length >= 6) { + //鍘绘帀娑堟伅澶�F 00 + data = data.Substring(4); + //Console.WriteLine($"{ip}-{data}"); + } + } + + internal static bool OpenOrCloseDoor(string doorCode, int state) + { + var plc = Settings.SafeDoorDevices.FirstOrDefault(a=>a.DeviceCode == doorCode); + if (plc != null) + { + if (state == 1023)//杩涘叆瀹夊叏闂�+ { + byte[] its = new byte[] {0x3F, 0x00, 0x11, 0x0d, 0x0a }; + if (!TcpServer.isSend.ContainsKey(plc.IPAddress)) + { + TcpServer.isSend.Add(plc.IPAddress, true); + } + else + { + TcpServer.isSend[plc.IPAddress] = true; + } + return TcpServer.TcpServerSend( plc.IPAddress, its); + } + + if (state == 1025)//绂诲紑瀹夊叏闂�+ { + byte[] its = new byte[] { 0x3F, 0x00, 0x10, 0x0d, 0x0a }; + if (!TcpServer.isSend.ContainsKey(plc.IPAddress)) + { + TcpServer.isSend.Add(plc.IPAddress, true); + } + else + { + TcpServer.isSend[plc.IPAddress] = true; + } + return TcpServer.TcpServerSend(plc.IPAddress, its); + } + } + return false; + } + } +} diff --git a/process/TaskProcess.cs b/process/TaskProcess.cs new file mode 100644 index 0000000..aaa7228 --- /dev/null +++ b/process/TaskProcess.cs @@ -0,0 +1,217 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.core; +using HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.util; +using HH.WCS.Mobox3.DoubleCoin.wms; +using Newtonsoft.Json; +using Opc.Ua; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; +using Org.BouncyCastle.Crypto; +using HH.WCS.Mobox3.DoubleCoin.device; + +namespace HH.WCS.Mobox3.DoubleCoin.process { + internal class TaskProcess { + #region 浠诲姟鐩稿叧 + //--------------------------------------------------浠诲姟鐩稿叧-------------------------------------------------- + /// <summary> + /// 鍙栬揣鍗歌揣瀹屾垚锛岀紦瀛樹綅鐘舵�鏇存柊 + /// </summary> + /// <param name="mst"></param> + /// <param name="load"></param> + internal static void CacheBitUpdate(TN_Task mst, bool load) { + var trayCarryCount = mst.N_CNTR_COUNT > 0 ? mst.N_CNTR_COUNT : 1; + if (load) { + + LogHelper.Info($"浠诲姟{mst.S_CODE} 璐т綅{mst.S_START_LOC}鍙栬揣瀹屾垚锛岃捣鐐硅В缁戝鍣▄mst.S_CNTR_CODE}"); + LocationHelper.UnBindingLoc(mst.S_START_LOC, mst.S_CNTR_CODE.Split(',').ToList()); + } + else { + + LogHelper.Info($"浠诲姟{mst.S_CODE} 璐т綅{mst.S_END_LOC}鍗歌揣瀹屾垚锛岀粓鐐圭粦瀹氬鍣▄mst.S_CNTR_CODE}"); + LocationHelper.BindingLoc(mst.S_END_LOC, mst.S_CNTR_CODE.Split(',').ToList()); + } + + } + + /// <summary> + /// 浠诲姟鍙栨秷锛岀紦瀛樹綅鐘舵�鏇存柊 + /// </summary> + /// <param name="mst"></param> + internal static void CacheBitCancelUpdate(TN_Task mst) + { + + if (WCSHelper.CheckActionRecordExist(mst.S_CODE, 5)) { + //鏍规嵁瀹㈡埛鐜板満瑕佹眰锛屽鏋滄湁5锛屽紑濮嬪嵏璐э紝鍦�涔嬪墠浜哄伐澶勭悊锛岃捣鐐圭粓鐐归噸缃紝5鍚庣粓鐐圭粦瀹�+ //缁堢偣缁戝畾 + CacheBitUpdate(mst, false); + WCSHelper.End(mst);//浠诲姟鐘舵�鏀规垚缁撴潫 + } + else { + //璧风偣瑙i攣 + LocationHelper.ErrorLocCntReset(new ErrorLocCntResetInfo() { locID = mst.S_START_LOC,reqCode =1}); + WCSHelper.Fail(mst);//浠诲姟鐘舵�鏀规垚閿欒 + } + LocationHelper.UnLockLoc(mst.S_END_LOC); + } + + + + /// <summary> + /// 浠诲姟鐘舵�鏇存柊澶勭悊 + /// </summary> + /// <param name="mst"></param> + /// <param name="state"></param> + internal static void OperateStatus(TN_Task mst, int state) { + if (state == 4) + { + CacheBitUpdate(mst, true); + } + if (state == 6)//鍗歌揣瀹屾垚 + { + CacheBitUpdate(mst, false); + } + if (state == 7) + { + CacheBitCancelUpdate(mst); + } + } + + /// <summary> + /// 瀹夊叏璇锋眰 + /// </summary> + /// <param name="no"></param> + /// <param name="state"></param> + /// <param name="forkliftNo"></param> + /// <param name="extData"></param> + internal static void OperateReq(string no, int state, string forkliftNo, string extData = "") + { + if (state == 1101) + { + //璇锋眰鍙栬揣锛�+ } + if (state == 1102) + { + //璇锋眰鍗歌揣锛�+ //鏍规嵁缁堢偣鍒ゆ柇锛屾槸cb02鐨勫叆鍙o紝鍒ゆ柇鍐呭瓨涓姸鎬侊紙瑕佺姸鎬佹椂闂达級锛屽厑璁稿嵏璐э紝閫氱煡agv鏀瑰弬鏁�+ var dic = new Dictionary<string, string>(); + //< Req >< Order No = 'TN2302020002' ParamNo = '18' Param1 = '12' /></ Req > + dic.Add("No", no); + dic.Add("ParamNo", "8"); + dic.Add("Param1", "1"); + NDC.ChangeOrder(dic); + //鏀瑰畬鍙傛暟杞﹀瓙灏变細鑷繁鍗歌揣 + } + if (state == 1103) + { + //澶ч搧妗嗗弶璧颁互鍚庨�鐭ワ紝鎴戜滑瑕侀�鐭ヨ緭閫佺嚎 + } + } + + private static object locLocker = new object(); + + + /// <summary> + /// 鎺ㄩ�浠诲姟 + /// </summary> + /// <param name="mst"></param> + internal static bool SendTask(TN_Task mst) + { + + var result = false; + var start = "0"; var end = "0"; + var taskType = mst.S_TYPE.Trim(); + if (mst.N_B_STATE == 0) { + if (mst.N_SCHEDULE_TYPE == 1)//閫氳繃NDC锛宧osttoagv璋冨害璁惧 + { + start = LocationHelper.GetAgvSite(mst.S_START_LOC); + end = LocationHelper.GetAgvSite(mst.S_END_LOC); + + if (mst.S_TYPE == "绌烘墭涓嬬嚎鍫嗗彔") + { + end = LocationHelper.GetAgvSite(mst.S_END_LOC,true); + } + + LogHelper.Info($"NDC鎺ㄩ�浠诲姟 {mst.S_CODE};" + "start=" + start + "end= " + end); + var startLoc = LocationHelper.GetLoc(mst.S_START_LOC); + var endLoc = LocationHelper.GetLoc(mst.S_END_LOC); + var dic = new List<param>(); + dic.Add(new param() { name = "IKey", value = "IKey" }); + dic.Add(new param() { name = "From", value = start.ToString() }); + dic.Add(new param() { name = "To", value = end.ToString() }); + dic.Add(new param() { name = "FUNC", value = startLoc.N_LAYER.ToString() }); + + dic.Add(new param() { name = "Ctype", value = "0" }); + + + if (mst.S_TYPE == "浣欐枡涓嬬嚎鍏ュ簱" || mst.S_TYPE == "浜哄伐鎷嗙洏鍏ュ簱") + { + dic.Add(new param() { name = "DATA", value = "1024" }); + } + else + { + dic.Add(new param() { name = "DATA", value = "0" }); + } + + var res = NDCApi.AddOrderNew(1, 1, mst.S_CODE, dic);//娣诲姞鏂板懡浠�+ if (res != null && (res.err_code == 0 || res.err_code == 50009)) + { + //鎺ㄩ�鎴愬姛锛屼慨鏀逛换鍔′紭鍏堢骇 + mst.N_B_STATE = 1; + mst.S_B_STATE = TN_Task.GetStateStr(1); + WCSHelper.UpdateStatus(mst);//鏇存柊浠诲姟鐘舵� + result = true; + LogHelper.Info($"NDC鎺ㄩ�浠诲姟鎴愬姛 {mst.S_CODE}start= {mst.S_START_LOC} + end = {mst.S_END_LOC}"); + } + else + { + LogHelper.Info($"NDC鎺ㄩ�浠诲姟澶辫触 {mst.S_CODE};Res:" + JsonConvert.SerializeObject(res)); + } + } + else if (mst.N_SCHEDULE_TYPE == 5)//閫氳繃鏉ゥ璋冨害璁惧 + { + //璋冪涓夋柟鎺ュ彛 + var model = new HanAo.TaskInfoModel + { + requestPk = mst.S_CODE, + frmPos = mst.S_START_LOC, + toPos = mst.S_END_LOC, + trkType = mst.S_OP_NAME == "鍏ュ簱" ? "1" : "2", + contNo = mst.S_CNTR_CODE + }; + if (HanAo.CreateOrder(model)) { + mst.N_B_STATE = 1; + WCSHelper.UpdateStatus(mst); + LogHelper.Info($"鏉ゥ鎺ㄩ�浠诲姟鎴愬姛 {mst.S_CODE};" + "start=" + model.frmPos + "end= " + model.toPos); + } + else + { + LogHelper.Info($"鏉ゥ鎺ㄩ�浠诲姟澶辫触 {mst.S_CODE};" + JsonConvert.SerializeObject(model)); + } + } + else if (mst.N_SCHEDULE_TYPE == 3) //閫氳繃鍥借嚜璋冨害璁惧 + { + var code = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, JsonConvert.SerializeObject(new { src = mst.S_START_LOC, dst = mst.S_END_LOC }), "p2p"); + if (code > 0) { + //鏇存柊浠诲姟鐘舵� + mst.N_B_STATE = 1; + mst.S_EQ_TASK_CODE = code.ToString(); + WCSHelper.UpdateStatus(mst); + WCSHelper.UpdateEQNo(mst); + LogHelper.Info($"鍥借嚜鎺ㄩ�浠诲姟鎴愬姛 {mst.S_CODE};" + "start=" + mst.S_START_LOC + "end= " + mst.S_END_LOC); + } + else + { + LogHelper.Info($"鍥借嚜鎺ㄩ�浠诲姟澶辫触 {mst.S_CODE};" + JsonConvert.SerializeObject(mst)); + } + } + + } + return result; + } + #endregion + } +} diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..e02abfc --- /dev/null +++ b/readme.txt @@ -0,0 +1 @@ +锘�diff --git a/swagger.js b/swagger.js new file mode 100644 index 0000000..aed0f8c --- /dev/null +++ b/swagger.js @@ -0,0 +1,110 @@ +'use strict'; +window.SwaggerTranslator = { + _words: [], + + translate: function () + { + var $this = this; + $('[data-sw-translate]').each(function () + { + $(this).html($this._tryTranslate($(this).html())); + $(this).val($this._tryTranslate($(this).val())); + $(this).attr('title', $this._tryTranslate($(this).attr('title'))); + }); + }, + + setControllerSummary: function () + { + $.ajax({ + type: "get", + async: true, + url: $("#input_baseUrl").val(), + dataType: "json", + success: function (data) + { + var summaryDict = data.ControllerDesc; + var id, controllerName, strSummary; + $("#resources_container .resource").each(function (i, item) + { + id = $(item).attr("id"); + if (id) + { + controllerName = id.substring(9); + strSummary = summaryDict[controllerName]; + if (strSummary) + { + $(item).children(".heading").children(".options").first().prepend('<li class="controller-summary" title="' + strSummary + '">' + strSummary + '</li>'); + } + } + }); + } + }); + }, + _tryTranslate: function (word) + { + return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word; + }, + + learn: function (wordsMap) + { + this._words = wordsMap; + } +}; + + +/* jshint quotmark: float */ +window.SwaggerTranslator.learn({ + "Warning: Deprecated": "警告:已过时", + "Implementation Notes": "实现备注", + "Response Class": "响应类", + "Status": "状态", + "Parameters": "参数", + "Parameter": "参数", + "Value": "值", + "Description": "描述", + "Parameter Type": "参数类型", + "Data Type": "数据类型", + "Response Messages": "响应消息", + "HTTP Status Code": "HTTP 状态码", + "Reason": "原因", + "Response Model": "响应模型", + "Request URL": "请求 URL", + "Response Body": "响应体", + "Response Code": "响应码", + "Response Headers": "响应头", + "Hide Response": "隐藏响应", + "Headers": "头", + "Try it out!": "试一下!", + "Show/Hide": "显示/隐藏", + "List Operations": "显示操作", + "Expand Operations": "展开操作", + "Raw": "原始", + "can't parse JSON. Raw result": "无法解析 JSON。原始结果", + "Model Schema": "模型架构", + "Model": "模型", + "apply": "应用", + "Username": "用户名", + "Password": "密码", + "Terms of service": "服务条款", + "Created by": "创建者", + "See more at": "查看更多:", + "Contact the developer": "联系开发者", + "api version": "api 版本", + "Response Content Type": "响应 Content Type", + "fetching resource": "正在获取资源", + "fetching resource list": "正在获取资源列表", + "Explore": "浏览", + "Show Swagger Petstore Example Apis": "显示 Swagger Petstore 示例 Apis", + "Can't read from server. It may not have the appropriate access-control-origin settings.": "无法从服务器读取。可能没有正确设置 access-control-origin。", + "Please specify the protocol for": "请指定协议:", + "Can't read swagger JSON from": "无法读取 swagger JSON于", + "Finished Loading Resource Information. Rendering Swagger UI": "已加载资源信息。正在渲染 Swagger UI", + "Unable to read api": "无法读取 api", + "from path": "从路径", + "server returned": "服务器返回" +}); +$(function () +{ + window.SwaggerTranslator.translate(); + window.SwaggerTranslator.setControllerSummary(); +}); \ No newline at end of file diff --git a/util/HttpHelper.cs b/util/HttpHelper.cs new file mode 100644 index 0000000..28969bc --- /dev/null +++ b/util/HttpHelper.cs @@ -0,0 +1,286 @@ +锘縰sing System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; + +namespace HH.WCS.Mobox3.DoubleCoin.util { + public class HttpHelper { + public string WebPost(string url, string postData, string cotentType = "application/json") + { + Console.WriteLine(url); + WebRequest request = WebRequest.Create(url); + request.Method = "POST"; + //string postData = JsonConvert.SerializeObject(data); ; + byte[] byteArray = Encoding.UTF8.GetBytes(postData); + request.ContentType = cotentType; + request.ContentLength = byteArray.Length; + request.Timeout = 3000; + StreamReader reader = null; + Stream dataStream = null; + WebResponse response = null; + + try + { + dataStream = request.GetRequestStream(); + dataStream.Write(byteArray, 0, byteArray.Length); + dataStream.Close(); + response = request.GetResponse(); + //Console.WriteLine(((HttpWebResponse)response).StatusDescription); + dataStream = response.GetResponseStream(); + reader = new StreamReader(dataStream, Encoding.UTF8); + string responseFromServer = reader.ReadToEnd(); + return responseFromServer; + } + catch (Exception e) + { + LogHelper.Info($"WebPost res={e.Message}", "API"); + return ""; + } + finally + { + // 閲婃斁璧勬簮 + if (reader != null) reader.Close(); + if (dataStream != null) dataStream.Close(); + if (response != null) response.Close(); + } + } + + public string WebGet(string url) { + WebRequest request = WebRequest.Create(url); + request.Timeout = 6000; + request.Method = "GET"; + StreamReader reader = null; + Stream dataStream = null; + WebResponse response = null; + try { + response = request.GetResponse(); + dataStream = response.GetResponseStream(); + reader = new StreamReader(dataStream); + string responseFromServer = reader.ReadToEnd(); + + Console.WriteLine(responseFromServer); + return responseFromServer; + } + catch (Exception e) { + LogHelper.Info($"WebGet res={e.Message}", "API"); + return ""; + } + finally + { + // 閲婃斁璧勬簮 + if (reader != null) reader.Close(); + if (dataStream != null) dataStream.Close(); + if (response != null) response.Close(); + } + } + + public string Get(string url, string contentType = "application/x-www-form-urlencoded") { + WebRequest request = WebRequest.Create(url); + request.Method = "Get"; + request.ContentType = contentType; + StreamReader reader = null; + Stream stream = null; + WebResponse rsp = null; + try { + + rsp = request.GetResponse(); + stream = rsp.GetResponseStream(); + reader = new StreamReader(stream); + return reader.ReadToEnd(); + } + catch (Exception e) + { + LogHelper.Info($"Get res={e.Message}", "API"); + return ""; + } + finally { + // 閲婃斁璧勬簮 + if (reader != null) reader.Close(); + if (stream != null) stream.Close(); + if (rsp != null) rsp.Close(); + } + + } + + public string Post(string url, string postData, string contentType = "application/json", string sessionId = "") { + Console.WriteLine(url); + WebRequest request = WebRequest.Create(url); + request.Method = "POST"; + byte[] byteArray = Encoding.UTF8.GetBytes(postData); + request.ContentType = contentType; + request.ContentLength = byteArray.Length; + request.Timeout = 3000; + if (sessionId != "") { + request.Headers.Set("ASP.NET_SessionId", sessionId); + } + StreamReader reader = null; + Stream stream = null; + WebResponse rsp = null; + try { + stream = request.GetRequestStream(); + stream.Write(byteArray, 0, byteArray.Length); + stream.Close(); + rsp = request.GetResponse(); + stream = rsp.GetResponseStream(); + reader = new StreamReader(stream); + return reader.ReadToEnd(); + } + catch (Exception ex) { + LogHelper.Info($"Post res={ex.Message}", "API"); + return ""; + } + finally { + // 閲婃斁璧勬簮 + if (reader != null) reader.Close(); + if (stream != null) stream.Close(); + if (rsp != null) rsp.Close(); + } + + } + + public string Post(string url, Dictionary<string, string> dic) { + var param = dic.Select(a => { return string.Format("{0}={1}", a.Key, a.Value); }).ToList(); + return Post(url, string.Join("&", param), "application/x-www-form-urlencoded"); + } + + public string PostWithCookie(string url, string sessinId) { + return PostWithCookie(url, "", "", sessinId); + } + + public string PostWithCookie(string url, string postData, string contentType = "application/json", string sessionId = "") { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + request.Method = "POST"; + byte[] byteArray = Encoding.UTF8.GetBytes(postData); + request.ContentType = contentType; + request.ContentLength = byteArray.Length; + if (sessionId != "") { + request.CookieContainer = new CookieContainer(); + request.CookieContainer.SetCookies(new Uri("http://" + request.RequestUri.Authority), "ASP.NET_SessionId=" + sessionId); + } + StreamReader reader = null; + Stream stream = null; + WebResponse rsp = null; + try { + stream = request.GetRequestStream(); + stream.Write(byteArray, 0, byteArray.Length); + stream.Close(); + rsp = request.GetResponse(); + stream = rsp.GetResponseStream(); + reader = new StreamReader(stream); + return reader.ReadToEnd(); + } + catch (Exception e) + { + + LogHelper.Info($"PostWithCookie res={e.Message}", "API"); + return ""; + } + finally { + // 閲婃斁璧勬簮 + if (reader != null) reader.Close(); + if (stream != null) stream.Close(); + if (rsp != null) rsp.Close(); + } + + } + + public string Put(string url, string postData, string contentType = "application/json", string sessionId = "") + { + WebRequest request = WebRequest.Create(url); + request.Method = "Put"; + byte[] byteArray = Encoding.UTF8.GetBytes(postData); + request.ContentType = contentType; + request.ContentLength = byteArray.Length; + if (sessionId != "") + { + request.Headers.Set("ASP.NET_SessionId", sessionId); + } + StreamReader reader = null; + Stream stream = null; + WebResponse rsp = null; + try + { + stream = request.GetRequestStream(); + stream.Write(byteArray, 0, byteArray.Length); + stream.Close(); + rsp = request.GetResponse(); + stream = rsp.GetResponseStream(); + reader = new StreamReader(stream); + return reader.ReadToEnd(); + } + catch (Exception e) + { + LogHelper.Info($"Put res={e.Message}", "API"); + return ""; + } + finally + { + // 閲婃斁璧勬簮 + if (reader != null) reader.Close(); + if (stream != null) stream.Close(); + if (rsp != null) rsp.Close(); + } + } + + public string WebPostWithMD5(string url, string postData, string contentType = "application/json") + { + // 鏂板鎺堟潈鍙傛暟 + string appKey = ""; // 鍋囪閰嶇疆绫讳腑鏈堿ppKey鍜孉ppSecret + string appSecret = ""; + string reqTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); + string reqVerify = CalculateMD5Hash($"{appKey}{appSecret}{reqTime}"); + + WebRequest request = WebRequest.Create(url); + request.Method = "POST"; + request.Headers.Add("AppKey", appKey); + request.Headers.Add("ReqTime", reqTime); + request.Headers.Add("ReqVerify", reqVerify); + + byte[] byteArray = Encoding.UTF8.GetBytes(postData); + request.ContentType = contentType; + request.ContentLength = byteArray.Length; + request.Timeout = 3000; + StreamReader reader = null; + Stream dataStream = null; + WebResponse response = null; + + try + { + dataStream = request.GetRequestStream(); + dataStream.Write(byteArray, 0, byteArray.Length); + dataStream.Close(); + response = request.GetResponse(); + //Console.WriteLine(((HttpWebResponse)response).StatusDescription); + dataStream = response.GetResponseStream(); + reader = new StreamReader(dataStream, Encoding.UTF8); + string responseFromServer = reader.ReadToEnd(); + return responseFromServer; + } + catch (Exception e) + { + LogHelper.Info($"WebPost res={e.Message}", "API"); + return ""; + } + finally + { + // 閲婃斁璧勬簮 + if (reader != null) reader.Close(); + if (dataStream != null) dataStream.Close(); + if (response != null) response.Close(); + } + } + + // MD5璁$畻杈呭姪鏂规硶 + private static string CalculateMD5Hash(string input) + { + using (var md5 = System.Security.Cryptography.MD5.Create()) + { + byte[] inputBytes = Encoding.UTF8.GetBytes(input); + byte[] hashBytes = md5.ComputeHash(inputBytes); + return BitConverter.ToString(hashBytes).Replace("-", "").ToLower(); + } + } + } +} diff --git a/util/LogHelper.cs b/util/LogHelper.cs new file mode 100644 index 0000000..5040a10 --- /dev/null +++ b/util/LogHelper.cs @@ -0,0 +1,144 @@ +锘縰sing NLog; +using NLog.Common; +using NLog.Config; +using NLog.Targets; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin +{ + + public class LogHelper + { + public static Dictionary<string, ILogger> loggers = new Dictionary<string, ILogger>(); + + public static void Debug(string message, string name = "") { + ILogger logger = null; + if (loggers.Keys.Contains(name)) { + logger = loggers[name]; + } + else { + logger = LogFactory.CreateLogger(name); + if (logger != null) { + loggers.Add(name, logger); + } + else { + logger = LogFactory.CreateLogger("console"); + } + } + if (logger != null) { + logger.Debug(message); + } + } + + public static void Info(string message, string name = "") { + //logger.Info(message); + ILogger logger = null; + if (loggers.Keys.Contains(name)) { + logger = loggers[name]; + } + else { + logger = LogFactory.CreateLogger(name); + if (logger != null) { + loggers.Add(name, logger); + } + else { + logger = LogFactory.CreateLogger("infoFile"); + } + } + if (logger != null) { + logger.Info(message); + } + } + + public static void Error(string message, Exception ex, string name = "") { + //logger.Error(ex, message); + ILogger logger = null; + if (loggers.Keys.Contains(name)) { + logger = loggers[name]; + } + else { + logger = LogFactory.CreateLogger(name); + if (logger != null) { + loggers.Add(name, logger); + } + else { + logger = LogFactory.CreateLogger("errorFile"); + } + } + if (logger != null) { + logger.Error($"{message}{ex.StackTrace}"); + } + } + + + } + + internal class LogFactory + { + /// <summary> + /// 閫氳繃閰嶇疆鏂囦欢閰嶇疆鏃ュ織 + /// </summary> + static LogFactory() { + var loggerNames = new List<string>() { "HosttoagvTask", "HosttoagvCar", "NDC", "鏉ゥ","PLC","API","OPC"}; + LogManager.Configuration = DefaultConfig(loggerNames); + } + public static ILogger CreateLogger(string name) { + var logger = LogManager.GetLogger(name); + return logger; + } + + public static LoggingConfiguration DefaultConfig(List<string> loggerNames) { + var config = new LoggingConfiguration(); + loggerNames.ForEach(a => { + var target = new FileTarget(); + target.ArchiveAboveSize = 1024 * 1024 * 5;//姣忎釜鏂囦欢鏈�ぇ5M + target.ArchiveNumbering = ArchiveNumberingMode.DateAndSequence; + target.ArchiveFileName = @"${basedir}/Logs/" + a + "/{####}.txt"; + target.FileName = @"${basedir}/Logs/" + a + "/${shortdate}.txt";//褰撳墠鏂囦欢璺緞 + target.Layout = @"${longdate} | ${level:uppercase=false:padding=-5} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"; + + config.AddTarget(a, target); + config.AddRuleForOneLevel(LogLevel.Info, target, a); + }); + + + // 娣诲姞target-console + var consoleTarget = new ColoredConsoleTarget(); + consoleTarget.Layout = @"${longdate} | ${level:uppercase=false:padding=-5} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"; + + config.AddTarget("console", consoleTarget); + config.AddRule(LogLevel.Debug, LogLevel.Fatal, consoleTarget); + + //娣诲姞target-info + var infoFileTarget = new FileTarget(); + infoFileTarget.ArchiveAboveSize = 1024 * 1024 * 5;//姣忎釜鏂囦欢鏈�ぇ5M + infoFileTarget.ArchiveNumbering = ArchiveNumberingMode.DateAndSequence; + infoFileTarget.ArchiveFileName = @"${basedir}/Logs/Info/{####}.txt"; + infoFileTarget.FileName = @"${basedir}/Logs/Info/${shortdate}.txt";//褰撳墠鏂囦欢璺緞 + infoFileTarget.Layout = @"${longdate} | ${level:uppercase=false:padding=-5} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"; + + config.AddTarget("infoFile", infoFileTarget); + config.AddRuleForOneLevel(LogLevel.Info, infoFileTarget);//INFO鍐欏湪Info鏂囦欢 + + //娣诲姞target-err + var errorFileTarget = new FileTarget(); + errorFileTarget.ArchiveAboveSize = 1024 * 1024 * 5;//姣忎釜鏂囦欢鏈�ぇ5M + errorFileTarget.ArchiveNumbering = ArchiveNumberingMode.DateAndSequence; + errorFileTarget.ArchiveFileName = @"${basedir}/Logs/Error/{####}.txt"; + errorFileTarget.FileName = @"${basedir}/Logs/Error/${shortdate}.txt"; + errorFileTarget.Layout = @"${longdate} | ${level:uppercase=false:padding=-5} | ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"; + + config.AddTarget("errorFile", errorFileTarget); + config.AddRule(LogLevel.Error, LogLevel.Fatal, errorFileTarget); + + + return config; + } + + + } +} diff --git a/util/Settings.cs b/util/Settings.cs new file mode 100644 index 0000000..f01f441 --- /dev/null +++ b/util/Settings.cs @@ -0,0 +1,170 @@ +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; + + +namespace HH.WCS.Mobox3.DoubleCoin.util +{ + public class Settings + { + public static string HostToAgvServerUrl { get; set; } + public static string NDCApiUrl { get; set; } + public static string SqlServer { get; set; } + public static string WebApiUrl { get; set; } + public static string TCPServerIP { get; set; } + public static int TCPServerPort { get; set; } + public static bool S7TestMoni { get; set; } + public static bool IsOpenScanCode { get; set; } + + /// <summary> + /// 鎵�湁鐨勫簱鍖�+ /// </summary> + public static List<string> Areas { get; set; } + + /// <summary> + /// 鎵�湁浜х嚎淇℃伅鍒楄〃 + /// </summary> + public static List<ProductionLine> ProductionLines { get; set; } + + /// <summary> + /// 鎵�湁绉伴噸璁惧淇℃伅鍒楄〃 + /// </summary> + public static List<WeightDevice> WeightDevices { get; set; } + + /// <summary> + /// Agv璇诲崱鍣ㄤ俊鎭垪琛�+ /// </summary> + public static List<AgvScanDevice> AgvScanDevices { get; set; } + + /// <summary> + /// 鎵�湁瀹夊叏闂ㄨ缃�+ /// </summary> + public static List<SafeDoorDevice> SafeDoorDevices { get; set; } + + public static void Init() + { + LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 寮�"); + try + { + var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "/config/config.json"; + using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile)) + { + using (JsonTextReader reader = new JsonTextReader(file)) + { + JObject o = (JObject)JToken.ReadFrom(reader); + foreach (Newtonsoft.Json.Linq.JProperty keyValue in o.Properties()) + { + Console.WriteLine(keyValue.Name); + if (keyValue.Name == "SqlServer") + { + SqlServer = keyValue.Value.ToString(); + } + if (keyValue.Name == "NDCApiUrl") + { + NDCApiUrl = keyValue.Value.ToString(); + } + if (keyValue.Name == "WebApiUrl") + { + WebApiUrl = keyValue.Value.ToString(); + } + if (keyValue.Name == "TCPServerIP") + { + TCPServerIP = keyValue.Value.ToString(); + } + if (keyValue.Name == "TCPServerPort") + { + TCPServerPort = Convert.ToInt32(keyValue.Value); + } + if (keyValue.Name == "S7TestMoni") + { + S7TestMoni = (bool)(keyValue.Value); + } + if (keyValue.Name == "IsOpenScanCode") + { + IsOpenScanCode = (bool)(keyValue.Value); + } + if (keyValue.Name == "Areas") + { + Areas = JsonConvert.DeserializeObject<List<string>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "ProductionLine") + { + ProductionLines = JsonConvert.DeserializeObject<List<ProductionLine>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "WeightDevices") + { + WeightDevices = JsonConvert.DeserializeObject<List<WeightDevice>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "AgvScanDevice") + { + AgvScanDevices = JsonConvert.DeserializeObject<List<AgvScanDevice>>(keyValue.Value.ToString()); + } + if (keyValue.Name == "SafeDoorDevices") + { + SafeDoorDevices = JsonConvert.DeserializeObject<List<SafeDoorDevice>>(keyValue.Value.ToString()); + } + } + } + } + LogHelper.Info("鍔犺浇閰嶇疆鏂囦欢淇℃伅 瀹屾垚"); + } + catch (Exception ex) + { + LogHelper.Error("鍔犺浇閰嶇疆鏂囦欢澶辫触锛� + ex.Message, ex); + } + + } + + /// <summary> + /// 浜х嚎淇℃伅 + /// </summary> + public class ProductionLine + { + public string ProductionLine_IP { get; set; }//浜х嚎IP鍦板潃 + public string ProductionLine_Name { get; set; }//浜х嚎鐨勫悕绉�+ public int ProductionLine_Rack { get; set; }//浜х嚎鐨勬灦瀛愬彿 + public int ProductionLine_Slot { get; set; }//浜х嚎鐨勬彃妲藉彿 + public string PointIn { get; set; }//浜х嚎鐨勭┖鎵樹笂绾夸綅 + public string PointOut { get; set; }//浜х嚎鐨勬弧鎵樹笅绾夸綅 + } + + /// <summary> + /// 绉伴噸璁惧淇℃伅 + /// </summary> + public class WeightDevice + { + public string WeightDevice_IP { get; set; }//绉伴噸璁惧IP鍦板潃 + public string WeightDevice_Name { get; set; }//绉伴噸璁惧鐨勫悕绉�+ public int WeightDevice_Rack { get; set; }//绉伴噸璁惧鐨勬灦瀛愬彿 + public int WeightDevice_Slot { get; set; }//绉伴噸璁惧鐨勬彃妲藉彿 + public string Point { get; set; }//绉伴噸璁惧鐨勭偣浣�+ } + + /// <summary> + /// 璇诲崱鍣ㄨ澶�+ /// </summary> + public class AgvScanDevice + { + public string AgvCode { get; set; }//agv缂栧彿 + public string ScanAddress { get; set; }//agv璇诲崱鍣ㄥ湴鍧�+ public string ScanState { get; set; }//agv鐘舵� + } + + /// <summary> + /// 瀹夊叏闂ㄨ澶�+ /// </summary> + public class SafeDoorDevice + { + public string DeviceCode { get; set; }//璁惧浠e彿 + public string DeviceName { get; set; }//璁惧鍚嶇О + public string IPAddress { get; set; }//鍦板潃 + } + + public class SpeAndTime + { + public string Spe { get; set; } + public int Minute { get; set; } + } + } +} diff --git a/util/SqlHelper.cs b/util/SqlHelper.cs new file mode 100644 index 0000000..560da13 --- /dev/null +++ b/util/SqlHelper.cs @@ -0,0 +1,71 @@ +锘縰sing Newtonsoft.Json; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Linq.Expressions; + +namespace HH.WCS.Mobox3.DoubleCoin.util +{ + //https://www.donet5.com/Home/Doc + public class SqlHelper<T> where T : class, new() { + + /// <summary> + /// 濡傛灉鐢∣racle鏁版嵁闇�鍖匫racle.ManagedDataAccess/21.15.0锛岀幆澧僴etframework 4.62锛屽お鏂颁簡4.8鏈夌殑鏈嶅姟鍣ㄥ畨瑁呬笉涓婂幓 + /// </summary> + /// <param name="url"></param> + /// <returns></returns> + public SqlSugarClient GetInstance(string url = "") + { + //鍒涘缓鏁版嵁搴撳璞�+ SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() + { + ConnectionString = string.IsNullOrEmpty(url) ? Settings.SqlServer : url, + //ConnectionString = @"Data Source=192.168.1.198\sql2008;Initial Catalog=OIMobox;User ID=sa;Password=sa@2015", + DbType = DbType.SqlServer, + //ConnectionString = @"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=OIMobox)));User Id=system;Password=Am123123;", + //DbType = DbType.Oracle, + IsAutoCloseConnection = true, + InitKeyType = InitKeyType.Attribute//浠庣壒鎬ц鍙栦富閿嚜澧炰俊鎭�+ }); + + //鐩戞帶鎵�湁瓒呰繃1绉掔殑Sql + db.Aop.OnLogExecuted = (sql, p) => + { + //鎵ц鏃堕棿瓒呰繃1绉�+ if (db.Ado.SqlExecutionTime.TotalSeconds > 1) + { + Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(p.ToDictionary(it => it.ParameterName, it => it.Value))); + //浠g爜CS鏂囦欢鍚�+ var fileName = db.Ado.SqlStackTrace.FirstFileName; + //浠g爜琛屾暟 + var fileLine = db.Ado.SqlStackTrace.FirstLine; + //鏂规硶鍚�+ var FirstMethodName = db.Ado.SqlStackTrace.FirstMethodName; + } + //鐩稿綋浜嶦F鐨�PrintToMiniProfiler + }; + + //姣忔璁剧疆鏁板�鏃堕兘鍘婚櫎鍓嶅鍚庡绌烘牸 + db.Aop.DataExecuted = (value, entity) => { + entity.EntityColumnInfos.ToList().ForEach(a => { + var pvalue = entity.GetValue(a.PropertyName); + if (pvalue != null && pvalue.GetType() == typeof(String)) + { + entity.SetValue(a.PropertyName, pvalue.ToString().Trim()); + } + }); + }; + + //鎹浆鎹�(ExecuteCommand鎵嶄細鎷︽埅锛屾煡璇笉琛� + //db.Aop.DataExecuting = (value, entity) => { + // //var val=entity.EntityColumnInfo + // Console.WriteLine(entity.EntityName); + //}; + + return db; + } + } + +} diff --git a/wms/ContainerHelper.cs b/wms/ContainerHelper.cs new file mode 100644 index 0000000..a520adf --- /dev/null +++ b/wms/ContainerHelper.cs @@ -0,0 +1,141 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static HH.WCS.Mobox3.DoubleCoin.dispatch.NDC; + +namespace HH.WCS.Mobox3.DoubleCoin.wms { + /// <summary> + /// 瀹瑰櫒甯姪绫�+ /// </summary> + internal class ContainerHelper + { + /// <summary> + /// 瀹瑰櫒缁戝畾璐у搧 + /// </summary> + /// <param name="cnt"></param> + /// <param name="cGs"></param> + /// <returns></returns> + public static string BindingCG(string cnt, List<string> cGs) + { + var db = new SqlHelper<object>().GetInstance(); + var logs = $"瀹瑰櫒锛歿cnt}锛岃揣鍝侊細{JsonConvert.SerializeObject(cGs)}"; + try + { + var cntCgList = db.Queryable<TN_CG_Detail>().Where(a => cGs.Contains(a.S_CG_ID) && a.S_CNTR_CODE == cnt).ToList(); + + if (cntCgList.Count > 0) + { + cGs = cGs.Except(cntCgList.Select(a => a.S_CNTR_CODE).ToList()).ToList(); + } + + var bindCntCgList = new List<TN_CG_Detail>(); + foreach (var item in cGs) + { + bindCntCgList.Add(new TN_CG_Detail() { S_CNTR_CODE = cnt, S_CG_ID = item }); + } + + var log = JsonConvert.SerializeObject(bindCntCgList); + if (db.Insertable<TN_CG_Detail>(bindCntCgList).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆瀹瑰櫒璐у搧鍏崇郴琛ㄦ垚鍔燂紝{log}"); + } + else + { + LogHelper.Info($"鎻掑叆瀹瑰櫒璐у搧鍏崇郴琛ㄥけ璐ワ紝{log}"); + return "瀹瑰櫒缁戝畾璐у搧澶辫触锛� + logs; + } + + var cntid = db.Queryable<TN_Container>().First(a => a.S_CODE == cnt); + + if (cntid != null) + { + cntid.T_MODIFY = System.DateTime.Now; + log = JsonConvert.SerializeObject(cntid); + if (db.Updateable(cntid).UpdateColumns(it => new { it.T_MODIFY }).ExecuteCommand() > 0) + { + LogHelper.Info($"鏇存柊瀹瑰櫒琛ㄦ垚鍔燂紝{log}"); + } + else + { + LogHelper.Info($"鏇存柊瀹瑰櫒琛ㄥけ璐ワ紝{log}"); + return "瀹瑰櫒缁戝畾璐у搧澶辫触锛� + logs; + } + } + else + { + LogHelper.Info($"鍦ㄦ暟鎹簱涓湭鎵惧埌璇ュ鍣紝鏃犻渶鏇存柊锛屽鍣細{cnt}"); + } + return "瀹瑰櫒缁戝畾璐у搧鎴愬姛锛� + logs; + } + catch (Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯革紝璐т綅缁戝畾瀹瑰櫒澶辫触锛�); + return "瀹瑰櫒缁戝畾璐у搧澶辫触锛� + ex.Message; + } + } + + /// <summary> + /// 瀹瑰櫒瑙g粦璐у搧 + /// </summary> + /// <param name="cnt"></param> + /// <param name="cGs"></param> + /// <returns></returns> + public static string UnBindingCG(string cnt, List<string> cGs) + { + var db = new SqlHelper<object>().GetInstance(); + var logs = $"瀹瑰櫒锛歿cnt}锛岃揣鍝侊細{JsonConvert.SerializeObject(cGs)}"; + try + { + var cntCgList = db.Queryable<TN_CG_Detail>().Where(a => cGs.Contains(a.S_CG_ID) && a.S_CNTR_CODE == cnt).ToList(); + if (cntCgList.Count == 0) + { + LogHelper.Info($"瀹瑰櫒鏃犻渶瑙g粦璐у搧锛屽湪鏁版嵁搴撲腑鏈壘鍒皗JsonConvert.SerializeObject(cGs)}鐩稿叧鐨勫鍣ㄨ揣鍝佸叧绯昏〃淇℃伅"); + return "瀹瑰櫒鏃犻渶瑙g粦璐у搧锛岃В缁戞垚鍔� + logs; + } + cGs = cntCgList.Select(a => a.S_CG_ID).ToList(); + + var log = JsonConvert.SerializeObject(cGs); + if (db.Deleteable<TN_CG_Detail>().Where(it => cGs.Contains(it.S_CG_ID) && it.S_CNTR_CODE == cnt).ExecuteCommand() > 0) + { + LogHelper.Info($"鍒犻櫎瀹瑰櫒璐у搧鍏崇郴琛ㄦ垚鍔燂紝{log}"); + } + else + { + LogHelper.Info($"鍒犻櫎瀹瑰櫒璐у搧鍏崇郴琛ㄥけ璐ワ紝{log}"); + return "瀹瑰櫒缁戝畾璐у搧澶辫触锛� + logs; + } + + var CntId = db.Queryable<TN_Container>().First(a => a.S_CODE == cnt); + if (CntId != null) + { + CntId.T_MODIFY = System.DateTime.Now; + log = JsonConvert.SerializeObject(CntId); + if (db.Updateable(CntId).UpdateColumns(it => new { it.T_MODIFY }).ExecuteCommand() > 0) + { + LogHelper.Info($"鏇存柊瀹瑰櫒琛ㄦ垚鍔燂紝{log}"); + } + else + { + LogHelper.Info($"鏇存柊瀹瑰櫒琛ㄥけ璐ワ紝{log}"); + return "瀹瑰櫒缁戝畾璐у搧澶辫触锛� + logs; + } + + } + else + { + LogHelper.Info($"鍦ㄦ暟鎹簱涓湭鎵惧埌璇ュ鍣紝鏃犻渶鏇存柊锛屽鍣細{cnt}"); + } + return "瀹瑰櫒瑙g粦璐у搧鎴愬姛锛� + logs; + } + catch (Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯革紝璐т綅瑙g粦瀹瑰櫒澶辫触锛寋ex.Message}"); + return "瀹瑰櫒瑙g粦璐у搧澶辫触锛� + logs; + } + } + } +} diff --git a/wms/LocationHelper.cs b/wms/LocationHelper.cs new file mode 100644 index 0000000..26c56bb --- /dev/null +++ b/wms/LocationHelper.cs @@ -0,0 +1,606 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; + +namespace HH.WCS.Mobox3.DoubleCoin.wms { + public class LocationHelper + { + private static Dictionary<string, TN_Location> Locations = null; + + static LocationHelper() + { + try + { + //鍒濆鍖朙ocation鍔犲叆鍒板瓧鍏哥紦瀛�+ Locations = new Dictionary<string, TN_Location>(); + var list = GetAllLocList(); + if (list.Count > 0) + { + list.ForEach(a => + { + if (!Locations.ContainsKey(a.S_CODE)) + { + Locations.Add(a.S_CODE, a); + } + }); + } + //鍒濆鍖朙ocationExt鍔犲叆鍒伴泦鍚堢紦瀛�+ //LocationExts = new Dictionary<string, LocationExt>(); + //var exts = GetAllLocExtList(); + //if (exts.Count > 0) { + // exts.ForEach(a => { + // LocationExts.Add($"{a.S_LOC_CODE.Trim()}_{a.S_PICKUP_POINT.Trim()}", a); + // }); + //} + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + + /// <summary> + /// 鑾峰彇鎵�湁璐т綅淇℃伅 + /// </summary> + /// <returns></returns> + internal static List<TN_Location> GetAllLocList() + { + var db = new SqlHelper<object>().GetInstance(); + return db.Queryable<TN_Location>().ToList(); + } + + + internal static TN_Location GetLocation(string loc) + { + if (Locations.Keys.Contains(loc)) + { + return Locations[loc.Trim()]; + } + return null; + } + + /// <summary> + /// 鑾峰彇璐т綅绔欑偣淇℃伅 + /// </summary> + /// <param name="loc"></param> + /// <param name="isEmpty">鏄惁灞炰簬浜哄伐绌烘墭鍖哄埌绌烘墭缂撳瓨搴撳尯</param> + /// <returns></returns> + internal static string GetAgvSite(string loc,bool isEmpty = false) + { + var site = "0"; + if (Locations.Keys.Contains(loc.Trim()) && !isEmpty) + { + var Location = Locations[loc.Trim()]; + site = Location.S_AGV_SITE; + } + else + { + var Location = GetLoc(loc.Trim()); + if (Location != null) + { + site = Location.S_AGV_SITE; + + if (isEmpty) + { + if (Location.N_CURRENT_NUM == 0) + { + site = Location.S_AGV_SITE; + } + if (Location.N_CURRENT_NUM == 1) + { + site = Location.S_AGV_SITE2; + } + if (Location.N_CURRENT_NUM == 2) + { + site = Location.S_AGV_SITE3; + } + if (Location.N_CURRENT_NUM == 3) + { + site = Location.S_AGV_SITE4; + } + if (Location.N_CURRENT_NUM == 4) + { + site = Location.S_AGV_SITE5; + } + } + } + } + return site; + } + + internal static TN_Location GetLoc(string code) + { + var db = new SqlHelper<object>().GetInstance(); + return db.Queryable<TN_Location>().Where(a => a.S_CODE.Trim() == code).First(); + } + + internal static SimpleResult EmptyUnBind(EmptyUnBindInfo model) + { + SimpleResult simpleResult = new SimpleResult(); + try + { + var db = new SqlHelper<object>().GetInstance(); + var cgs = db.Queryable<TN_CG_Detail>().Where(a => a.S_CNTR_CODE == model.cntID).Select(a => a.S_ITEM_CODE).ToList(); + simpleResult.resultMsg = ContainerHelper.UnBindingCG(model.cntID, cgs); + if (simpleResult.resultMsg.Contains("鎴愬姛")) + { + simpleResult.resultCode = 0; + + Task task99 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "绾胯竟瑙g粦鎴愮┖鎵�, model.cntID); + }); + } + else + { + simpleResult.resultCode = 1; + } + return simpleResult; + } + catch (Exception ex) + { + simpleResult.resultCode = -1; + simpleResult.resultMsg = $"鍙戠敓浜嗗紓甯革紝璐т綅瑙g粦瀹瑰櫒澶辫触锛寋ex.Message}"; + LogHelper.Info(simpleResult.resultMsg); + return simpleResult; + } + } + + /// <summary> + /// 鍏ュ簱閿佸畾缁堢偣锛屽嚭搴撻攣瀹氳捣鐐�+ /// 浣犲垱寤轰换鍔¢攣瀹氳揣浣嶇殑鏃跺�锛屾妸閿佺殑鏉ユ簮灏辨槸浠诲姟鍙蜂篃鍐欎笂鍘伙紙鍔犻攣鐨勬柟娉曞姞涓弬鏁帮紝鍙┖鐨勫弬鏁帮級锛岃В閿佺殑鏃跺�鎶婃潵婧愮疆绌恒� + /// </summary> + /// <param name="loc"></param> + /// <param name="lockState">1:鍏ュ簱閿併�2:鍑哄簱閿併�2:鍏跺畠閿�/param> + /// <param name="lockSource">閿佺殑鏉ユ簮=浠诲姟鍙�/param> + /// <returns></returns> + public static bool LockLoc(string loc, int lockState, string lockSource = "") + { + var res = false; + var db = new SqlHelper<object>().GetInstance(); + var model = db.Queryable<TN_Location>().Where(a => a.S_CODE == loc).First(); + LogHelper.Info($"閿佽揣浣峽loc},鐘舵�{lockState},淇℃伅" + JsonConvert.SerializeObject(model)); + if (model != null && model.N_LOCK_STATE == 0) + { + model.N_LOCK_STATE = lockState; + model.S_LOCK_STATE = TN_Location.GetLockStateStr(lockState); + model.S_LOCK_OP = lockSource; + model.T_MODIFY = System.DateTime.Now; + res = db.Updateable<TN_Location>(model).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() > 0; + } + LogHelper.Info($"閿佽揣浣峽loc}杩斿洖{res}"); + + + return res; + } + + /// <summary> + /// 鍙栬揣瀹岃В閿佽捣鐐癸紝鍗歌揣瀹岃В閿佺粓鐐癸紝鍙楠岄攣鐨勬潵婧愶紝涔熷彲浠ヤ笉鏍¢獙 + /// </summary> + /// <param name="loc"></param> + /// <returns></returns> + public static bool UnLockLoc(string loc) + { + LogHelper.Info("UnLockLoc:" + loc); + var res = false; + var db = new SqlHelper<object>().GetInstance(); + var model = db.Queryable<TN_Location>().Where(a => a.S_CODE == loc).First(); + if (model != null) + { + model.S_LOCK_STATE = "鏃�; + model.N_LOCK_STATE = 0; + model.S_LOCK_OP = ""; + model.T_MODIFY = System.DateTime.Now; + res = db.Updateable(model).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() > 0; + LogHelper.Info("UnLockLoc:瑙i攣缁撴灉" + res); + } + else + { + LogHelper.Info("UnLockLoc 澶辫触" + loc); + } + return res; + } + + /// <summary> + /// 璐т綅瑙g粦瀹瑰櫒 + /// </summary> + /// <param name="loc"></param> + /// <param name="cntrs"></param> + /// <returns></returns> + public static string UnBindingLoc(string loc, List<string> cntrs) + { + var db = new SqlHelper<object>().GetInstance(); + var logs = $"璐т綅锛歿loc}锛屽鍣細{JsonConvert.SerializeObject(cntrs)}"; + try + { + var lcrList = db.Queryable<TN_Loc_Container>().Where(a => cntrs.Contains(a.S_CNTR_CODE) && a.S_LOC_CODE == loc).ToList(); + if (lcrList.Count == 0) + { + LogHelper.Info($"璐т綅鏃犻渶瑙g粦瀹瑰櫒锛屽湪鏁版嵁搴撲腑鏈壘鍒皗JsonConvert.SerializeObject(cntrs)}鐩稿叧鐨勮揣浣嶅鍣ㄥ叧绯昏〃淇℃伅"); + } + cntrs = lcrList.Select(a => a.S_CNTR_CODE).ToList(); + + + var log = JsonConvert.SerializeObject(cntrs); + var location = db.Queryable<TN_Location>().First(a => a.S_CODE == loc); + if (location != null) + { + location.N_CURRENT_NUM = 0; + location.S_LOCK_STATE = "鏃�; + location.N_LOCK_STATE = 0; + + using (var tran = db.Ado.UseTran()) + { + if (db.Deleteable<TN_Loc_Container>().Where(it => cntrs.Contains(it.S_CNTR_CODE) && it.S_LOC_CODE == loc).ExecuteCommand() > 0) + { + LogHelper.Info($"鍒犻櫎璐т綅瀹瑰櫒鍏崇郴琛ㄦ垚鍔燂紝{log}"); + } + else + { + tran.RollbackTran(); + + LogHelper.Info($"鍒犻櫎璐т綅瀹瑰櫒鍏崇郴琛ㄥけ璐ワ紝{log}"); + + return "璐т綅瑙g粦瀹瑰櫒澶辫触锛� + logs; + } + + log = JsonConvert.SerializeObject(location); + if (db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM, it.S_LOCK_STATE, it.N_LOCK_STATE }).ExecuteCommand() > 0) + { + tran.CommitTran(); + + LogHelper.Info($"鏇存柊璐т綅琛ㄦ垚鍔燂紝{log}"); + } + else + { + tran.RollbackTran(); + + LogHelper.Info($"鏇存柊璐т綅琛ㄥけ璐ワ紝{log}"); + + return "璐т綅瑙g粦瀹瑰櫒澶辫触锛� + logs; + } + } + } + else + { + LogHelper.Info($"鍦ㄦ暟鎹簱涓湭鎵惧埌璇ヨ揣浣嶏紝鏃犻渶鏇存柊锛岃揣浣嶏細{loc}"); + } + return "璐т綅瑙g粦瀹瑰櫒鎴愬姛锛� + logs; + } + catch (Exception ex) + { + + LogHelper.Info($"鍙戠敓浜嗗紓甯革紝璐т綅瑙g粦瀹瑰櫒澶辫触锛寋ex.Message}"); + return "璐т綅缁戝畾瀹瑰櫒澶辫触锛� + logs; + } + } + + + /// <summary> + /// 璐т綅缁戝畾瀹瑰櫒 + /// </summary> + /// <param name="loc"></param> + /// <param name="cntrs"></param> + /// <returns></returns> + public static string BindingLoc(string loc, List<string> cntrs) + { + var db = new SqlHelper<object>().GetInstance(); + var logs = $"璐т綅锛歿loc}锛屽鍣細{JsonConvert.SerializeObject(cntrs)}"; + try + { + var lcrList = db.Queryable<TN_Loc_Container>().Where(a => cntrs.Contains(a.S_CNTR_CODE) && a.S_LOC_CODE == loc).ToList(); + + if (lcrList.Count > 0) + { + cntrs = cntrs.Except(lcrList.Select(a => a.S_CNTR_CODE).ToList()).ToList(); + } + + var bindLocCntList = new List<TN_Loc_Container>(); + foreach (var item in cntrs) + { + bindLocCntList.Add(new TN_Loc_Container() { S_LOC_CODE = loc, S_CNTR_CODE = item }); + } + + + var log = JsonConvert.SerializeObject(bindLocCntList); + + using (var tran = db.Ado.UseTran()) + { + if (db.Insertable<TN_Loc_Container>(bindLocCntList).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛ㄦ垚鍔燂紝{log}"); + } + else + { + db.RollbackTran(); + LogHelper.Info($"鎻掑叆璐т綅瀹瑰櫒鍏崇郴琛ㄥけ璐ワ紝{log}"); + return "璐т綅缁戝畾瀹瑰櫒澶辫触锛� + logs; + } + + var location = db.Queryable<TN_Location>().First(a => a.S_CODE == loc); + if (location != null) + { + location.N_CURRENT_NUM += cntrs.Count; + location.S_LOCK_STATE = "鏃�; + location.N_LOCK_STATE = 0; + log = JsonConvert.SerializeObject(location); + + if (db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM, it.S_LOCK_STATE, it.N_LOCK_STATE }).ExecuteCommand() > 0) + { + db.CommitTran(); + + LogHelper.Info($"鏇存柊璐т綅琛ㄦ垚鍔燂紝{log}"); + } + else + { + db.RollbackTran(); + + LogHelper.Info($"鏇存柊璐т綅琛ㄥけ璐ワ紝{log}"); + + return "璐т綅缁戝畾瀹瑰櫒澶辫触锛� + logs; + } + } + else + { + db.RollbackTran(); + LogHelper.Info($"鏈壘鍒拌璐т綅{loc}锛屾垨鑰呭凡閿佸畾锛寋log}"); + } + } + return "璐т綅缁戝畾瀹瑰櫒鎴愬姛锛� + logs; + } + catch (Exception ex) + { + LogHelper.Info($"鍙戠敓浜嗗紓甯革紝璐т綅缁戝畾瀹瑰櫒澶辫触锛�); + return "璐т綅缁戝畾瀹瑰櫒澶辫触锛� + ex.Message; + } + } + + + /// <summary> + /// 浜哄伐鎵嬪姩PDA瑙g粦锛氬垹闄よ揣浣�瀹瑰櫒/璐у搧涓夋柟淇℃伅锛�=瑙g粦璐т綅涓庡鍣紝2=瑙g粦瀹瑰櫒涓庤揣鍝�+ /// </summary> + /// <param name="model"></EmptyUnBind> + /// <returns></returns> + internal static SimpleResult PdaUnBind(PdaUnBindInfo model) + { + var simpleResult = new SimpleResult(); + if (model.reqCode == 1) + { + var res = UnBindingLoc(model.locID, new List<string>() { model.cntID }); + simpleResult.resultCode = res.Contains("澶辫触") ? -1 : 0; + simpleResult.resultMsg = res; + if (simpleResult.resultCode == 0) + { + Task task99 = Task.Run(() => + { + WMSHelper.InsertOpInfo(model.staff, "浜哄伐鎵嬪姩PDA瑙g粦", model.cntID); + }); + } + + return simpleResult; + } + if (model.reqCode == 2) + { + var res = ContainerHelper.UnBindingCG(model.cntID, new List<string>() { model.CgId }); + simpleResult.resultCode = res.Contains("澶辫触") ? -1 : 0; + simpleResult.resultMsg = res; + + if (simpleResult.resultCode == 0) + { + //Task task99 = Task.Run(() => + //{ + // WMSHelper.InsertOpInfo(model.staff, "浜哄伐鎵嬪姩PDA瑙g粦", model.cntID); + //}); + } + return simpleResult; + } + simpleResult.resultCode = 3; + simpleResult.resultMsg = "浜哄伐鎵嬪姩PDA瑙g粦锛氬垹闄よ揣浣�瀹瑰櫒/璐у搧涓夋柟淇℃伅锛�=瑙g粦璐т綅涓庡鍣紝2=瑙g粦瀹瑰櫒涓庤揣鍝�; + return simpleResult; + } + + /// <summary> + /// 寮傚父璐т綅瀹瑰櫒閲嶇疆锛氶噸缃揣浣�瀹瑰櫒/璐у搧涓夋柟淇℃伅锛�=鏍规嵁璐т綅閲嶇疆锛�=鐩存帴鏍规嵁瀹瑰櫒閲嶇疆 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult ErrorLocCntReset(ErrorLocCntResetInfo model) + { + LogHelper.Info("瑙﹀彂API锛氳揣浣嶅鍣ㄩ噸缃� + JsonConvert.SerializeObject(model), "API"); + + var result = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + + try + { + if (model.locID != string.Empty && model.reqCode == 1) + { + var locCntrRels = db.Queryable<TN_Loc_Container>().Where(a => a.S_LOC_CODE == model.locID).ToList(); + + if (locCntrRels.Count == 0) + { + result.resultCode = 2; + result.resultMsg = $"鏈壘鍒拌揣浣嶅鍣ㄥ叧绯讳俊鎭瘂model.locID}"; + LogHelper.Info(result.resultMsg); + return result; + } + + foreach (var item in locCntrRels) + { + var cG_Detail = db.Queryable<TN_CG_Detail>().Where(a => a.S_CNTR_CODE == item.S_CNTR_CODE).ToList(); + if (cG_Detail.Count > 0) + { + if (db.Deleteable<TN_CG_Detail>(cG_Detail).ExecuteCommand() <= 0) + { + LogHelper.Info($"鍒犻櫎瀹瑰櫒{model.cntID}璐у搧鏄庣粏琛ㄤ俊鎭け璐�); + continue; + } + } + } + if (db.Deleteable<TN_Loc_Container>(locCntrRels).ExecuteCommand() <= 0) + { + result.resultCode = 3; + result.resultMsg = $"鍒犻櫎璐т綅{model.locID}瀹瑰櫒{model.cntID}鍏崇郴琛ㄤ俊鎭け璐�; + LogHelper.Info(result.resultMsg); + return result; + } + + var loc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.locID); + if (loc != null) + { + loc.N_CURRENT_NUM = 0; + loc.N_LOCK_STATE = 0; + loc.S_LOCK_STATE = "鏃�; + loc.C_ENABLE = "Y"; + if (db.Updateable<TN_Location>(loc).UpdateColumns(it => new { it.N_CURRENT_NUM, it.N_LOCK_STATE, it.S_LOCK_STATE, it.C_ENABLE }).ExecuteCommand() <= 0) + { + result.resultCode = 4; + result.resultMsg = $"鏇存柊璐т綅{loc.S_CODE}淇℃伅澶辫触"; + LogHelper.Info(result.resultMsg); + return result; + } + } + string ackLog = $"閲嶇疆鎴愬姛锛岃揣浣峽model.locID}锛屽鍣▄JsonConvert.SerializeObject(locCntrRels.Select(a => a.S_CNTR_CODE).ToList())}"; + LogHelper.Info(ackLog); + result.resultCode = 0; + result.resultMsg = ackLog; + return result; + } + + if (model.cntID != string.Empty && model.reqCode == 2) + { + var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == model.cntID); + var cG_Detail = db.Queryable<TN_CG_Detail>().Where(a => a.S_CNTR_CODE == locCntrRel.S_CNTR_CODE).ToList(); + if (cG_Detail.Count > 0) + { + if (db.Deleteable<TN_CG_Detail>(cG_Detail).ExecuteCommand() <= 0) + { + result.resultCode = 5; + result.resultMsg = $"鍒犻櫎瀹瑰櫒{model.cntID}璐у搧鏄庣粏琛ㄤ俊鎭け璐�; + LogHelper.Info(result.resultMsg); + return result; + } + } + var loc = db.Queryable<TN_Location>().First(a => a.S_CODE == locCntrRel.S_LOC_CODE); + if (loc != null) + { + loc.N_CURRENT_NUM = 0; + loc.N_LOCK_STATE = 0; + loc.S_LOCK_STATE = "鏃�; + loc.C_ENABLE = "Y"; + if (db.Updateable<TN_Location>(loc).UpdateColumns(it => new { it.N_CURRENT_NUM, it.N_LOCK_STATE, it.S_LOCK_STATE, it.C_ENABLE }).ExecuteCommand() <= 0) + { + result.resultCode = 6; + result.resultMsg = $"鏇存柊璐т綅{loc.S_CODE}淇℃伅澶辫触"; + LogHelper.Info(result.resultMsg); + return result; + } + } + } + result.resultCode = 0; + result.resultMsg = $"閲嶇疆鎴愬姛锛屽鍣▄model.cntID}"; + LogHelper.Info(result.resultMsg); + return result; + } + catch (Exception ex) + { + result.resultCode = -1; + result.resultMsg = $"鍙戠敓浜嗗紓甯革細{ex.Message}"; + LogHelper.Info(result.resultMsg); + return result; + } + } + + public static string GetStrByOk(int state) + { + if (state == 0) + { + return "鍚堟牸"; + } + if (state == 1) + { + return "寰呮"; + } + if (state == 2) + { + return "涓嶅悎鏍�; + } + return "寰呮"; + } + } + + public class PdaUnBindInfo + { + public string cntID { get; set; }//瀹瑰櫒ID + public string locID { get; set; }//璐т綅ID + public string CgId { get; set; }//鐗╂枡缂栫爜 + public int reqCode { get; set; }//璇锋眰浠g爜 + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class EmptyUnBindInfo + { + public string cntID { get; set; }//瀹瑰櫒ID + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class CancleTaskInfo + { + public string taskNO { get; set; }//浠诲姟鍙�+ + + } + + public class PDAFullInAreaInfo + { + public string StartLoc { get; set; }//璧风偣 + public string RfId { get; set; }//瀹瑰櫒鍙�+ public string Spe { get; set; }//瑙勬牸 + public string CarCode { get; set; }//杞﹀彿 + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class ErrorLocCntResetInfo + { + public string cntID { get; set; }//瀹瑰櫒ID + public string locID { get; set; }//璐т綅ID + public int reqCode { get; set; }//璇锋眰浠g爜 + } + + public class PDAFullCheckInfo + { + public string rfId { get; set; }//瀹瑰櫒鍙�+ + /// <summary> + /// 0鍚堟牸1寰呮2涓嶅悎鏍硷紝涓嬬嚎鍗冲緟妫�+ /// </summary> + public int cgState { get; set; }//鐗╂枡鐘舵� + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } + + public class ShowCntCountBySpeInfo + { + public string Spe { get; set; }//瑙勬牸 + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ + } + + public class PDAReturnResetInfo + { + public string rfId { get; set; }//瀹瑰櫒鍙�+ + public string startLoc { get; set; }//璧风偣璐т綅 + + public string staff { get; set; } = "None";//鎿嶄綔浜�+ } +} diff --git a/wms/SYSHelper.cs b/wms/SYSHelper.cs new file mode 100644 index 0000000..db120cb --- /dev/null +++ b/wms/SYSHelper.cs @@ -0,0 +1,43 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.util; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.wms +{ + internal class SYSHelper + { + private static object locker = new object(); + internal static int GetSerialNumber(string snType, string prefix) { + int result = 0; + lock (locker) { + var db = new SqlHelper<object>().GetInstance(); + var sId = db.Queryable<OI_SYS_MAXID>().Where(a => a.CN_S_TYPE.Trim() == snType && a.CN_S_PRE.Trim() == prefix).First(); + if (sId != null) { + sId.CN_N_MAX++; + if (db.Ado.ExecuteCommand($"update OI_SYS_MAXID set CN_N_MAX={sId.CN_N_MAX} where CN_S_TYPE='{snType}' and CN_S_PRE='{prefix}' ") > 0) { + result = sId.CN_N_MAX; + } + } + else { + //鎻掑叆琛�+ sId = new OI_SYS_MAXID { CN_S_TYPE = snType, CN_S_PRE = prefix, CN_N_MAX = 1 }; + result = db.Insertable<OI_SYS_MAXID>(sId).ExecuteCommand() > 0 ? 1 : 0; + + } + } + return result; + } + + [SugarTable("dbo.OI_SYS_MAXID")] + public class OI_SYS_MAXID + { + public string CN_S_TYPE { get; set; } + public string CN_S_PRE { get; set; } + public int CN_N_MAX { get; set; } + } + } +} diff --git a/wms/SpecHelper.cs b/wms/SpecHelper.cs new file mode 100644 index 0000000..12c9718 --- /dev/null +++ b/wms/SpecHelper.cs @@ -0,0 +1,389 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.models; +using HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.wms +{ + public class SpecHelper + { + + /// <summary> + /// 鑾峰彇闈欑疆鏃堕棿 + /// </summary> + /// <param name="spec"></param> + /// <returns></returns> + public static int GetWaitTime(string spec) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var specConfig = db.Queryable<TN_TN_SPE>().First(o => o.S_SPE == spec); + if (specConfig != null) + { + return specConfig.N_STANDING_TIME ?? 1; + } + else + { + return 1; + } + } + catch (Exception ex) + { + LogHelper.Error("鑾峰彇闈欑疆鏃堕棿澶辫触", ex); + return 1; + } + } + + /// <summary> + /// 鑾峰彇杩囨湡鏃堕棿 + /// </summary> + /// <param name="spec"></param> + /// <returns></returns> + public static int GetExportTime(string spec) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var specConfig = db.Queryable<TN_TN_SPE>().First(o => o.S_SPE == spec); + if (specConfig != null) + { + return specConfig.N_EXPIRE_TIME ?? 1; + } + else + { + return 1; + } + } + catch (Exception ex) + { + LogHelper.Error("鑾峰彇杩囨湡鏃堕棿澶辫触", ex); + return 1; + } + } + + /// <summary> + /// 鎻掑叆璁惧鐢熶骇鏄庣粏 + /// </summary> + public static void InsertEquipProDetail(TN_EquipProDetail model) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var log = JsonConvert.SerializeObject(model); + if (model != null) + { + model.Expiration = System.DateTime.Now.AddMinutes(GetExportTime(model.Spec)); + + if (db.Insertable<TN_EquipProDetail>(model).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆璁惧鐢熶骇鏄庣粏鎴愬姛锛寋log}"); + } + else + { + LogHelper.Info($"鎻掑叆璁惧鐢熶骇鏄庣粏澶辫触锛寋log}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鎻掑叆璁惧鐢熶骇鏄庣粏澶辫触", ex); + } + } + + /// <summary> + /// 鏇存柊璁惧鐢熶骇鏄庣粏鐨勮繃鏈熸椂闂�+ /// </summary> + public static void UpdateEquipProDetail(string cg_SID) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var target = db.Queryable<TN_EquipProDetail>().First(a => a.S_ID == cg_SID); + if (target != null) + { + target.Expiration = System.DateTime.Now.AddMinutes(GetExportTime(target.Spec)); + db.Updateable<TN_EquipProDetail>().UpdateColumns(it => new { it.Expiration }).ExecuteCommand(); + } + } + catch (Exception ex) + { + LogHelper.Error("鎻掑叆璁惧鐢熶骇鏄庣粏澶辫触", ex); + } + } + + + /// <summary> + /// 鎻掑叆閮ㄤ欢鐢ㄦ枡鏄庣粏 + /// </summary> + /// <param name="model"></param> + public static void InsertComponentDetail(TN_Component_Detail model) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var log = JsonConvert.SerializeObject(model); + if (model != null) + { + model.OutAreaTime = System.DateTime.Now; + model.Type = "婊℃墭鍑哄簱涓婄嚎"; + + if (db.Insertable<TN_Component_Detail>(model).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆閮ㄤ欢鐢ㄦ枡鏄庣粏鎴愬姛锛寋log}"); + } + else + { + LogHelper.Info($"鎻掑叆閮ㄤ欢鐢ㄦ枡鏄庣粏澶辫触锛寋log}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鎻掑叆閮ㄤ欢鐢ㄦ枡鏄庣粏澶辫触", ex); + } + } + + /// <summary> + /// 鏇存柊閮ㄤ欢鐢ㄦ枡鏄庣粏 + /// </summary> + public static void UpdateComponentDetail(string taskNo) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var target = db.Queryable<TN_Component_Detail>().First(o => o.TaskNo == taskNo); + + if (target != null) + { + target.EndTime = System.DateTime.Now; + + if (db.Updateable<TN_Component_Detail>(target).ExecuteCommand() > 0) + { + LogHelper.Info($"鏇存柊閮ㄤ欢鐢ㄦ枡鏄庣粏鎴愬姛锛寋taskNo}"); + } + else + { + LogHelper.Info($"鏇存柊閮ㄤ欢鐢ㄦ枡鏄庣粏澶辫触锛寋taskNo}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鏇存柊閮ㄤ欢鐢ㄦ枡鏄庣粏澶辫触", ex); + } + } + + + /// <summary> + /// 鎻掑叆鍥炵倝鏂欐槑缁�+ /// </summary> + /// <param name="model"></param> + public static void InsertRemeltDetail(TN_RemeltDetail model) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var log = JsonConvert.SerializeObject(model); + if (model != null) + { + model.RemeltTime = System.DateTime.Now; + + if (db.Insertable<TN_RemeltDetail>(model).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆鍥炵倝鏂欐槑缁嗘垚鍔燂紝{log}"); + } + else + { + LogHelper.Info($"鎻掑叆鍥炵倝鏂欐槑缁嗗け璐ワ紝{log}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鎻掑叆鍥炵倝鏂欐槑缁嗗け璐�, ex); + } + } + + /// <summary> + /// 鏇存柊鍥炵倝鏂欐槑缁�+ /// </summary> + public static void UpdateRemeltDetail(string taskNo) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var target = db.Queryable<TN_RemeltDetail>().First(o => o.TaskNo == taskNo); + + if (target != null) + { + target.EndTime = System.DateTime.Now; + + if (db.Updateable<TN_RemeltDetail>(target).ExecuteCommand() > 0) + { + LogHelper.Info($"鏇存柊鍥炵倝鏂欐槑缁嗘垚鍔燂紝{taskNo}"); + } + else + { + LogHelper.Info($"鏇存柊鍥炵倝鏂欐槑缁嗗け璐ワ紝{taskNo}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鏇存柊鍥炵倝鏂欐槑缁嗗け璐�, ex); + } + } + + + /// <summary> + /// 鎻掑叆浣欐枡鍥炲簱鏄庣粏 + /// </summary> + /// <param name="model"></param> + public static void InsertSurplusDetail(TN_SurplusDetail model) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var log = JsonConvert.SerializeObject(model); + if (model != null) + { + model.RemeltTime = System.DateTime.Now; + + if (db.Insertable<TN_SurplusDetail>(model).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆浣欐枡鍥炲簱鏄庣粏鎴愬姛锛寋log}"); + } + else + { + LogHelper.Info($"鎻掑叆浣欐枡鍥炲簱鏄庣粏澶辫触锛寋log}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鎻掑叆浣欐枡鍥炲簱鏄庣粏澶辫触", ex); + } + } + + /// <summary> + /// 鏇存柊浣欐枡鍥炲簱鏄庣粏 + /// </summary> + public static void UpdateSurplusDetail(string taskNo) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var target = db.Queryable<TN_SurplusDetail>().First(o => o.TaskNo == taskNo); + + if (target != null) + { + target.EndTime = System.DateTime.Now; + + if (db.Updateable<TN_SurplusDetail>(target).ExecuteCommand() > 0) + { + LogHelper.Info($"鏇存柊浣欐枡鍥炲簱鏄庣粏鎴愬姛锛寋taskNo}"); + } + else + { + LogHelper.Info($"鏇存柊浣欐枡鍥炲簱鏄庣粏澶辫触锛寋taskNo}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鏇存柊浣欐枡鍥炲簱鏄庣粏澶辫触", ex); + } + } + + /// <summary> + /// 鏇存柊浣欐枡鍥炲簱鏄庣粏 + /// </summary> + public static void UpdateSurplusDetail(string taskNo,float weight) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var target = db.Queryable<TN_SurplusDetail>().First(o => o.TaskNo == taskNo); + + if (target != null) + { + target.Weight = weight; + if (db.Updateable<TN_SurplusDetail>(target).ExecuteCommand() > 0) + { + LogHelper.Info($"鏇存柊浣欐枡鍥炲簱鏄庣粏鎴愬姛锛寋taskNo}"); + } + else + { + LogHelper.Info($"鏇存柊浣欐枡鍥炲簱鏄庣粏澶辫触锛寋taskNo}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鏇存柊浣欐枡鍥炲簱鏄庣粏澶辫触", ex); + } + } + + /// <summary> + /// 鎻掑叆WMS搴撳瓨鏄庣粏 + /// </summary> + /// <param name="model"></param> + public static void InsertInventoryM(TN_InventoryM model) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var log = JsonConvert.SerializeObject(model); + + if (model != null) + { + var target = db.Queryable<TN_InventoryM>().First(o => o.RFID == model.RFID); + if (target != null) + { + db.Deleteable<TN_InventoryM>(target).ExecuteCommand(); + } + model.Expiration = System.DateTime.Now.AddMinutes(GetExportTime(model.Spec)); + if (db.Insertable<TN_InventoryM>(model).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆WMS搴撳瓨鏄庣粏鎴愬姛锛寋log}"); + } + else + { + LogHelper.Info($"鎻掑叆WMS搴撳瓨鏄庣粏澶辫触锛寋log}"); + } + } + } + catch (Exception ex) + { + LogHelper.Error("鎻掑叆WMS搴撳瓨鏄庣粏澶辫触", ex); + } + } + + + /// <summary> + /// 鏇存柊WMS搴撳瓨鏄庣粏鐨勮繃鏈熸椂闂�+ /// </summary> + public static void UpdateInventoryM(string cg_SID) + { + try + { + var db = new SqlHelper<object>().GetInstance(); + var target = db.Queryable<TN_InventoryM>().First(a => a.S_ID == cg_SID); + if (target != null) + { + target.Expiration = System.DateTime.Now.AddMinutes(GetExportTime(target.Spec)); + db.Updateable<TN_InventoryM>().UpdateColumns(it => new { it.Expiration }).ExecuteCommand(); + } + } + catch (Exception ex) + { + LogHelper.Error("鎻掑叆璁惧鐢熶骇鏄庣粏澶辫触", ex); + } + } + } +} diff --git a/wms/WCSHelper.cs b/wms/WCSHelper.cs new file mode 100644 index 0000000..f435aa9 --- /dev/null +++ b/wms/WCSHelper.cs @@ -0,0 +1,250 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.util; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HH.WCS.Mobox3.DoubleCoin.wms { + internal class WCSHelper { + internal static string GenerateTaskNo() { + var id = SYSHelper.GetSerialNumber("浠诲姟鍙�, "TN"); + var date = DateTime.Now.ToString("yyMMdd"); + return $"TN{date}{id.ToString().PadLeft(4, '0')}"; + } + internal static bool UpdateStatus(TN_Task task, string status) + { + var res = false; + var db = new SqlHelper<TN_Task>().GetInstance(); + task.S_B_STATE = status; + res = db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE }).ExecuteCommand()>0; + return res; + } + internal static bool UpdateStatus(TN_Task task) { + var res = false; + var db = new SqlHelper<TN_Task>().GetInstance(); + task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE); + task.T_MODIFY = DateTime.Now; + db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_MODIFY }).ExecuteCommand(); + return res; + } + internal static bool UpdateEQNo(TN_Task task) { + var res = false; + var db = new SqlHelper<TN_Task>().GetInstance(); + task.T_MODIFY = DateTime.Now; + db.Updateable(task).UpdateColumns(it => new { it.S_EQ_TASK_CODE, it.T_MODIFY }).ExecuteCommand(); + return res; + } + + internal static TN_Task GetTask(string no) { + var db = new SqlHelper<TN_Task>().GetInstance(); + var task = db.Queryable<TN_Task>().Where(a => a.S_CODE == no).First(); + return task; + } + + + + /// <summary> + /// 鍒涘缓鎼�浠诲姟 + /// </summary> + /// <param name="no">缂栧彿</param> + /// <param name="from">璧风偣</param> + /// <param name="to">缁堢偣</param> + /// <param name="taskType">浠诲姟绫诲瀷</param> + /// <param name="pri">浼樺厛绾�/param> + /// <param name="cntrInfo">瀹瑰櫒缂栫爜</param> + /// <param name="spec">鐗╂枡瑙勬牸</param> + /// <returns></returns> + internal static bool CreateTask(string from, string to, string taskType, int pri, string cntrInfo,string spec = "") + { + var fromLoc = LocationHelper.GetLocation(from); + var endLoc = LocationHelper.GetLocation(to); + TN_Task TN_Task = new TN_Task() + { + S_CODE = GenerateTaskNo(), + S_START_AREA = fromLoc.S_AREA_CODE, + S_END_AREA = endLoc.S_AREA_CODE, + S_START_LOC = from, + S_END_LOC = to, + S_TYPE = taskType, + N_PRIORITY = pri, + N_SCHEDULE_TYPE = 1, + N_B_STATE = 0, + S_CNTR_CODE = cntrInfo, + }; + + var log = JsonConvert.SerializeObject(TN_Task); + var db = new SqlHelper<TN_Task>().GetInstance(); + + if (!string.IsNullOrEmpty(spec)) + { + TN_Task.S_SPEC = spec; + } + + var res = db.Insertable(TN_Task).ExecuteCommand() > 0; + if (res) + { + LogHelper.Info($"鎻掑叆浠诲姟鎴愬姛锛寋log}"); + } + else + { + LogHelper.Info($"鎻掑叆浠诲姟澶辫触锛寋log}"); + } + return res; + + } + + internal static bool CreateTask(string from, string to, string taskType, int pri, string cntrInfo, out string taskNo, string spec = "" ) + { + var fromLoc = LocationHelper.GetLocation(from); + var endLoc = LocationHelper.GetLocation(to); + TN_Task TN_Task = new TN_Task() + { + S_CODE = GenerateTaskNo(), + S_START_AREA = fromLoc.S_AREA_CODE, + S_END_AREA = endLoc.S_AREA_CODE, + S_START_LOC = from, + S_END_LOC = to, + S_TYPE = taskType, + N_PRIORITY = pri, + N_SCHEDULE_TYPE = 1, + N_B_STATE = 0, + S_CNTR_CODE = cntrInfo, + }; + taskNo = TN_Task.S_CODE; + var log = JsonConvert.SerializeObject(TN_Task); + var db = new SqlHelper<TN_Task>().GetInstance(); + + if (!string.IsNullOrEmpty(spec)) + { + TN_Task.S_SPEC = spec; + } + + var res = db.Insertable(TN_Task).ExecuteCommand() > 0; + if (res) + { + LogHelper.Info($"鎻掑叆浠诲姟鎴愬姛锛寋log}"); + } + else + { + LogHelper.Info($"鎻掑叆浠诲姟澶辫触锛寋log}"); + } + return res; + + } + + public static bool CreateTask(List<CreateTasks> modes) + { + if (modes != null && modes.Count > 0) + { + List<TN_Task> tN_Tasks = new List<TN_Task>(); + + foreach (var item in modes) + { + tN_Tasks.Add(new TN_Task() + { + S_CODE = item.taskNo, + S_START_AREA = item.fromArea, + S_END_AREA = item.toArea, + S_START_LOC = item.from, + S_END_LOC = item.to, + S_TYPE = item.taskType, + N_PRIORITY = item.pri, + N_SCHEDULE_TYPE = 1, + N_B_STATE = 0, + S_CNTR_CODE = item.cntrInfo, + S_SPEC = item.spec + }); + } + var log = JsonConvert.SerializeObject(tN_Tasks); + var db = new SqlHelper<object>().GetInstance(); + var res = db.Insertable<TN_Task>(tN_Tasks).ExecuteCommand() > 0; + if (res) + { + LogHelper.Info($"鎻掑叆浠诲姟鎴愬姛锛寋log}"); + } + else + { + LogHelper.Info($"鎻掑叆浠诲姟澶辫触锛寋log}"); + } + return res; + } + + return false; + } + + + internal static bool CheckActionRecordExist(string no, int code) { + var db = new SqlHelper<TN_Task_Action>().GetInstance(); + return db.Queryable<TN_Task_Action>().Count(a => a.S_TASK_CODE == no && a.N_ACTION_CODE == code) > 0; + } + + internal static void Begin(TN_Task task, string forklift_no) + { + var db = new SqlHelper<TN_Task>().GetInstance(); + if (task != null) + { + if (task.N_B_STATE == 1) + { + task.N_B_STATE = 2; + task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE); + task.T_START_TIME = System.DateTime.Now; + task.S_EQ_NO = forklift_no; + db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_START_TIME, it.S_EQ_NO }).ExecuteCommand(); + } + + } + } + internal static void End(TN_Task task) { + var db = new SqlHelper<TN_Task>().GetInstance(); + if (task != null) { + task.N_B_STATE = 3; + task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE); + task.T_END_TIME = DateTime.Now; + db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_END_TIME }).ExecuteCommand(); + } + } + internal static void Fail(TN_Task task) { + var db = new SqlHelper<TN_Task>().GetInstance(); + if (task != null) { + //鍒ゆ柇鏈夋病鏈夊彇璐у畬鎴愶紝娌℃湁灏卞彉鎴愬け璐ャ�鏈夊彇璐у畬鎴愰粯璁ゅ畬鎴愪簡锛堣窡鎹」鐩�瀹氾紝鏈変簺椤圭洰浜哄伐鎷夎蛋浜嗕篃娌℃湁鏀惧埌缁堢偣锛夈� + task.N_B_STATE = 4; + task.S_B_STATE = TN_Task.GetStateStr(task.N_B_STATE); + db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE }).ExecuteCommand(); + } + } + + internal static bool AddActionRecord(string no, int state, string forkliftNo, string extData) + { + var db = new SqlHelper<TN_Task_Action>().GetInstance(); + var action = new TN_Task_Action() + { + N_ACTION_CODE = state, + S_TASK_CODE = no, + S_EQ_CODE = forkliftNo, + S_EQ_TYPE = "agv", + S_DATA = extData + }; + return db.Insertable(action).ExecuteCommand() > 0; + } + + internal static List<TN_Task> GetWaitingTaskList() { + var db = new SqlHelper<object>().GetInstance(); + return db.Queryable<TN_Task>().Where(a => a.N_B_STATE == 0 && (a.S_B_STATE == "绛夊緟" || a.S_B_STATE == "寰呮帹閫�)).ToList(); + } + } + + public class CreateTasks + { + public string taskNo { set; get; } + public string from { set; get; } + public string fromArea { set; get; } + public string to { set; get; } + public string toArea { set; get; } + public string taskType { set; get; } + public int pri { set; get; } + public string cntrInfo { set; get; } + public string spec { set; get; } + } +} diff --git a/wms/WMSHelper.cs b/wms/WMSHelper.cs new file mode 100644 index 0000000..3fc5bde --- /dev/null +++ b/wms/WMSHelper.cs @@ -0,0 +1,127 @@ +锘縰sing HH.WCS.Mobox3.DoubleCoin.api; +using HH.WCS.Mobox3.DoubleCoin.dispatch; +using HH.WCS.Mobox3.DoubleCoin.models; +using HH.WCS.Mobox3.DoubleCoin.util; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Runtime.Remoting.Messaging; +using System.Text; +using System.Threading.Tasks; +using static HH.WCS.Mobox3.DoubleCoin.api.ApiModel; + +namespace HH.WCS.Mobox3.DoubleCoin.wms +{ + /// <summary> + /// wms绠″埌浣滀笟 + /// </summary> + internal class WMSHelper + { + /// <summary> + /// 浜哄伐鎵嬪姩PDA鍙栨秷浠诲姟锛�=鍙戠粰AGV鍙栨秷浠诲姟 + /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static SimpleResult PDACancleTask(CancleTaskInfo model) + { + SimpleResult simpleResult = new SimpleResult(); + var db = new SqlHelper<object>().GetInstance(); + try + { + if (model.taskNO.Length > 0) + { + var task = db.Queryable<TN_Task>().First(a => a.S_CODE == model.taskNO); + if (task != null && task.S_B_STATE != "瀹屾垚") + { + if (NDCApi.CancelOrder(model.taskNO).err_code == 0) + { + task.S_B_STATE = "閿欒"; + task.N_B_STATE = 4; + if (db.Updateable<TN_Task>(task).ExecuteCommand() > 0) + { + simpleResult.resultCode = 0; + simpleResult.resultMsg = $"閫氱煡AGV鍙栨秷璇ヤ换鍔″彿锛屾垚鍔燂紝{model.taskNO}"; + LogHelper.Info(simpleResult.resultMsg); + return simpleResult; + } + else + { + simpleResult.resultCode = 4; + simpleResult.resultMsg = $"鏇存柊浠诲姟鐘舵�淇℃伅澶辫触{model.taskNO}"; + LogHelper.Info(simpleResult.resultMsg); + return simpleResult; + } + } + else + { + simpleResult.resultCode = 1; + simpleResult.resultMsg = $"閫氱煡AGV鍙栨秷璇ヤ换鍔″彿锛屽け璐ワ紝{model.taskNO}"; + LogHelper.Info(simpleResult.resultMsg); + return simpleResult; + } + + } + else + { + simpleResult.resultCode = 2; + simpleResult.resultMsg = $"鏈壘鍒拌浠诲姟鍙锋垨璇ヤ换鍔″彿宸插畬鎴愶紝鏃犻渶閫氱煡AGV鍙栨秷"; + LogHelper.Info(simpleResult.resultMsg); + return simpleResult; + } + + } + else + { + simpleResult.resultCode = 3; + simpleResult.resultMsg = $"浜哄伐鎵嬪姩PDA鍙栨秷浠诲姟锛�=鍙戠粰AGV鍙栨秷浠诲姟锛屽弬鏁版棤鏁�; + LogHelper.Info(simpleResult.resultMsg); + return simpleResult; + } + } + catch (Exception ex) + { + simpleResult.resultCode = -1; + simpleResult.resultMsg = $"鍙戠敓浜嗗紓甯竰ex.Message}"; + LogHelper.Info(simpleResult.resultMsg); + return simpleResult; + } + } + + + public static void InsertOpInfo(string staff, string type , string cntrCode ="",int qty = 0) + { + try + { + if(string.IsNullOrEmpty(staff)) + { + LogHelper.Info($"鎿嶄綔鍛樹俊鎭负绌猴紝{staff}"); + return; + } + + var db = new SqlHelper<object>().GetInstance(); + var target = new TN_Operator_Info() + { + S_STAFF = staff, + S_SNTR_CODE = cntrCode, + F_QTY = qty, + S_TYPE = type + }; + + if(db.Insertable<TN_Operator_Info>(target).ExecuteCommand() > 0) + { + LogHelper.Info($"鎻掑叆鎿嶄綔鍛樹俊鎭垚鍔燂紝{staff}"); + } + else + { + LogHelper.Info($"鎻掑叆鎿嶄綔鍛樹俊鎭け璐ワ紝{staff}"); + } + } + catch(Exception ex) + { + LogHelper.Error($"鎻掑叆鎿嶄綔鍛樹俊鎭紝鍙戠敓浜嗗紓甯革紝{ex.Message}",ex); + } + } + } +} -- Gitblit v1.9.1