From ed670b6b4a44a11060a7527809c84ff4c32ba6a6 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期六, 12 七月 2025 15:39:52 +0800
Subject: [PATCH] 1.AGV接口开发 2.采购扫描验退

---
 service/Warehouse/MesCgthSqManager.cs        |  161 ++++++++++
 NewPdaSqlServer.csproj                       |    1 
 Controllers/Warehouse/MesCgthSqController.cs |   55 +++
 service/Warehouse/MesBarCFManager.cs         |    7 
 Controllers/AGV/AgvApiController.cs          |  218 ++++++++++++++
 Controllers/AGV/MesClient.cs                 |  402 ++++++++++++++++++++++++++
 Controllers/AGV/app.config                   |   15 +
 7 files changed, 858 insertions(+), 1 deletions(-)

diff --git a/Controllers/AGV/AgvApiController.cs b/Controllers/AGV/AgvApiController.cs
new file mode 100644
index 0000000..e9776fa
--- /dev/null
+++ b/Controllers/AGV/AgvApiController.cs
@@ -0,0 +1,218 @@
+using System.Dynamic;
+using Azure;
+using Microsoft.AspNetCore.Mvc;
+using NewPdaSqlServer.Dto.service;
+using NewPdaSqlServer.entity;
+using NewPdaSqlServer.util;
+using Newtonsoft.Json.Linq;
+using System.ServiceModel;
+using System.IO;
+
+namespace NewPdaSqlServer.Controllers.AGV;
+
+[Route("api/[controller]")]
+[ApiController]
+public class AgvApiController : ControllerBase
+{
+    OaApiService m = new OaApiService();
+
+    //鍦ㄧ被鍐呮坊鍔犳棩蹇楁柟娉�
+    // private void LogToFile(string methodName, object request, string response)
+    //{
+    //    string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs", $"AgvLog_{DateTime.Now:yyyyMMdd}.log");
+    //    Directory.CreateDirectory(Path.GetDirectoryName(logPath));
+
+    //    string logContent = $"[{DateTime.Now:HH:mm:ss}] 鏂规硶锛歿methodName}\n" +
+    //                       $"璇锋眰鍙傛暟锛歿JObject.FromObject(request)}\n" +
+    //                       $"鍝嶅簲缁撴灉锛歿response}\n\n";
+
+    //    File.AppendAllText(logPath, logContent);
+    //}
+
+    // 淇敼鐜版湁鏂规硶锛堜互AgvTest涓轰緥锛�
+    [HttpPost("AgvTest")]
+    public ResponseResult AgvTest(dynamic queryObj)
+    {
+        try
+        {
+            var binding = new BasicHttpBinding { /* 鍘熸湁閰嶇疆 */ };
+            var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet");
+            var factory = new ChannelFactory<IImesInterface>(binding, endpoint);
+            
+            var channel = factory.CreateChannel();
+            string result = channel.PrintHello();
+            ((IClientChannel)channel).Close();
+    
+            // 璁板綍鏃ュ織
+            //LogToFile(nameof(AgvTest), new { queryObj }, result);
+    
+            return new ResponseResult { status = 0, message = "OK", data = result };
+        }
+        catch (Exception ex)
+        {
+            //LogToFile(nameof(AgvTest), new { queryObj }, $"寮傚父锛歿ex}");
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    //绔嬪簱閫佹
+    [HttpPost("DefineTask_001")]
+    public ResponseResult DefineTask_001(dynamic queryObj)
+    {
+        try
+        {
+            var binding = new BasicHttpBinding
+            {
+                MaxReceivedMessageSize = 10485760, // 10MB
+                TextEncoding = System.Text.Encoding.UTF8
+            };
+
+            var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet");
+            var factory = new ChannelFactory<IImesInterface>(binding, endpoint);
+
+            var channel = factory.CreateChannel();
+            string result = channel.DefineTask_001("GS2025070700001","TEST.01","AGV娴嬭瘯鐗╂枡鍚嶇О", "AGV娴嬭瘯鐗╂枡瑙勬牸",100,"鍙�",1);
+            ((IClientChannel)channel).Close();
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = result
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    //绔嬪簱妫�楠�
+    [HttpPost("DefineTask_002")]
+    public ResponseResult DefineTask_002(dynamic queryObj)
+    {
+        try
+        {
+            var binding = new BasicHttpBinding
+            {
+                MaxReceivedMessageSize = 10485760, // 10MB
+                TextEncoding = System.Text.Encoding.UTF8
+            };
+
+            var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet");
+            var factory = new ChannelFactory<IImesInterface>(binding, endpoint);
+
+            var channel = factory.CreateChannel();
+            string result = channel.DefineTask_002("GS2025070900010", "鍚堟牸");
+            ((IClientChannel)channel).Close();
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = result
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    //绔嬪簱鍛煎彨
+    [HttpPost("DefineTask_005")]
+    public ResponseResult DefineTask_005(dynamic queryObj)
+    {
+        try
+        {
+            var binding = new BasicHttpBinding
+            {
+                MaxReceivedMessageSize = 10485760, // 10MB
+                TextEncoding = System.Text.Encoding.UTF8
+            };
+
+            var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet");
+            var factory = new ChannelFactory<IImesInterface>(binding, endpoint);
+
+            var channel = factory.CreateChannel();
+            string result = channel.DefineTask_005();
+            ((IClientChannel)channel).Close();
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = result
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+
+    //绔嬪簱鍏ュ簱
+    [HttpPost("DefineTask_006")]
+    public ResponseResult DefineTask_006(dynamic queryObj)
+    {
+        try
+        {
+            var binding = new BasicHttpBinding
+            {
+                MaxReceivedMessageSize = 10485760, // 10MB
+                TextEncoding = System.Text.Encoding.UTF8
+            };
+
+            var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet");
+            var factory = new ChannelFactory<IImesInterface>(binding, endpoint);
+
+            var channel = factory.CreateChannel();
+            string result = channel.DefineTask_006("C2025070400040", "2.02.51.463", "绠$嚎楗按鏈�", "C638-1HA(涓囧拰VGX-SR-1A-XM鐧�)", 48, "鍙�", 4);
+            ((IClientChannel)channel).Close();
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = result
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+
+
+}
+
+// 鍦ㄧ被澶栭儴娣诲姞鏈嶅姟濂戠害鎺ュ彛
+[ServiceContract(Namespace = "http://tempuri.org/")]
+public interface IImesInterface
+{
+    [OperationContract(Action = "http://tempuri.org/ImesInterface/PrintHello", 
+                      ReplyAction = "http://tempuri.org/ImesInterface/PrintHelloResponse")]
+    string PrintHello();
+
+    //绔嬪簱閫佹
+    [OperationContract(Action = "http://tempuri.org/ImesInterface/DefineTask_001",
+              ReplyAction = "http://tempuri.org/ImesInterface/DefineTask_001Response")]
+    string DefineTask_001(string MesId, string MatId, string MatName, string MatStandard, int MatNumber, string MatUnit, int Postition);
+
+    //绔嬪簱妫�楠�
+    [OperationContract(Action = "http://tempuri.org/ImesInterface/DefineTask_002",
+          ReplyAction = "http://tempuri.org/ImesInterface/DefineTask_002Response")]
+    string DefineTask_002(string MesId, string MatStatus);
+
+    //绔嬪簱鍛煎彨
+    [OperationContract(Action = "http://tempuri.org/ImesInterface/DefineTask_005",
+                  ReplyAction = "http://tempuri.org/ImesInterface/DefineTask_005Response")]
+    string DefineTask_005();
+
+    //绔嬪簱鍏ュ簱
+    [OperationContract(Action = "http://tempuri.org/ImesInterface/DefineTask_006",
+              ReplyAction = "http://tempuri.org/ImesInterface/DefineTask_006Response")]
+    string DefineTask_006(string MesId,string MatId,string MatName,string MatStandard,int MatNumber,string MatUnit,int Postition);
+}
\ No newline at end of file
diff --git a/Controllers/AGV/MesClient.cs b/Controllers/AGV/MesClient.cs
new file mode 100644
index 0000000..be5c50f
--- /dev/null
+++ b/Controllers/AGV/MesClient.cs
@@ -0,0 +1,402 @@
+锘�//------------------------------------------------------------------------------
+// <auto-generated>
+//     姝や唬鐮佺敱宸ュ叿鐢熸垚銆�
+//     杩愯鏃剁増鏈�:4.0.30319.42000
+//
+//     瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋�
+//     閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便��
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+
+
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ImesInterface")]
+public interface ImesInterface
+{
+    
+    // CODEGEN: 鍛藉悕绌洪棿  鐨勫厓绱犲悕绉� PrintHelloResult 浠ュ悗鐢熸垚鐨勬秷鎭崗瀹氭湭鏍囪涓� nillable
+    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ImesInterface/PrintHello", ReplyAction="http://tempuri.org/ImesInterface/PrintHelloResponse")]
+    PrintHelloResponse PrintHello(PrintHelloRequest request);
+    
+    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ImesInterface/PrintHello", ReplyAction="http://tempuri.org/ImesInterface/PrintHelloResponse")]
+    System.Threading.Tasks.Task<PrintHelloResponse> PrintHelloAsync(PrintHelloRequest request);
+    
+    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ImesInterface/DefineTask_001", ReplyAction="http://tempuri.org/ImesInterface/DefineTask_001Response")]
+    DefineTask_001Response DefineTask_001(DefineTask_001Request request);
+    
+    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ImesInterface/DefineTask_001", ReplyAction="http://tempuri.org/ImesInterface/DefineTask_001Response")]
+    System.Threading.Tasks.Task<DefineTask_001Response> DefineTask_001Async(DefineTask_001Request request);
+    
+    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ImesInterface/DefineTask_006", ReplyAction="http://tempuri.org/ImesInterface/DefineTask_006Response")]
+    DefineTask_006Response DefineTask_006(DefineTask_006Request request);
+    
+    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ImesInterface/DefineTask_006", ReplyAction="http://tempuri.org/ImesInterface/DefineTask_006Response")]
+    System.Threading.Tasks.Task<DefineTask_006Response> DefineTask_006Async(DefineTask_006Request request);
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+public partial class PrintHelloRequest
+{
+    
+    [System.ServiceModel.MessageBodyMemberAttribute(Name="PrintHello", Namespace="http://tempuri.org/", Order=0)]
+    public PrintHelloRequestBody Body;
+    
+    public PrintHelloRequest()
+    {
+    }
+    
+    public PrintHelloRequest(PrintHelloRequestBody Body)
+    {
+        this.Body = Body;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+[System.Runtime.Serialization.DataContractAttribute()]
+public partial class PrintHelloRequestBody
+{
+    
+    public PrintHelloRequestBody()
+    {
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+public partial class PrintHelloResponse
+{
+    
+    [System.ServiceModel.MessageBodyMemberAttribute(Name="PrintHelloResponse", Namespace="http://tempuri.org/", Order=0)]
+    public PrintHelloResponseBody Body;
+    
+    public PrintHelloResponse()
+    {
+    }
+    
+    public PrintHelloResponse(PrintHelloResponseBody Body)
+    {
+        this.Body = Body;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+[System.Runtime.Serialization.DataContractAttribute(Namespace="")]
+public partial class PrintHelloResponseBody
+{
+    
+    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
+    public string PrintHelloResult;
+    
+    public PrintHelloResponseBody()
+    {
+    }
+    
+    public PrintHelloResponseBody(string PrintHelloResult)
+    {
+        this.PrintHelloResult = PrintHelloResult;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+public partial class DefineTask_001Request
+{
+    
+    [System.ServiceModel.MessageBodyMemberAttribute(Name="DefineTask_001", Namespace="http://tempuri.org/", Order=0)]
+    public DefineTask_001RequestBody Body;
+    
+    public DefineTask_001Request()
+    {
+    }
+    
+    public DefineTask_001Request(DefineTask_001RequestBody Body)
+    {
+        this.Body = Body;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.Runtime.Serialization.DataContractAttribute(Namespace="")]
+public partial class DefineTask_001RequestBody
+{
+    
+    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
+    public string taskName;
+    
+    [System.Runtime.Serialization.DataMemberAttribute(Order=1)]
+    public int taskId;
+    
+    public DefineTask_001RequestBody()
+    {
+    }
+    
+    public DefineTask_001RequestBody(string taskName, int taskId)
+    {
+        this.taskName = taskName;
+        this.taskId = taskId;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+public partial class DefineTask_001Response
+{
+    
+    [System.ServiceModel.MessageBodyMemberAttribute(Name="DefineTask_001Response", Namespace="http://tempuri.org/", Order=0)]
+    public DefineTask_001ResponseBody Body;
+    
+    public DefineTask_001Response()
+    {
+    }
+    
+    public DefineTask_001Response(DefineTask_001ResponseBody Body)
+    {
+        this.Body = Body;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.Runtime.Serialization.DataContractAttribute(Namespace="")]
+public partial class DefineTask_001ResponseBody
+{
+    
+    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
+    public string DefineTaskResult;
+    
+    [System.Runtime.Serialization.DataMemberAttribute(Order=1)]
+    public int taskStatusCode;
+    
+    public DefineTask_001ResponseBody()
+    {
+    }
+    
+    public DefineTask_001ResponseBody(string DefineTaskResult, int taskStatusCode)
+    {
+        this.DefineTaskResult = DefineTaskResult;
+        this.taskStatusCode = taskStatusCode;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+public partial class DefineTask_006Request
+{
+    
+    [System.ServiceModel.MessageBodyMemberAttribute(Name="DefineTask_006", Namespace="http://tempuri.org/", Order=0)]
+    public DefineTask_006RequestBody Body;
+    
+    public DefineTask_006Request()
+    {
+    }
+    
+    public DefineTask_006Request(DefineTask_006RequestBody Body)
+    {
+        this.Body = Body;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.Runtime.Serialization.DataContractAttribute(Namespace="")]
+public partial class DefineTask_006RequestBody
+{
+    
+    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
+    public string taskName;
+    
+    [System.Runtime.Serialization.DataMemberAttribute(Order=1)]
+    public int taskId;
+    
+    public DefineTask_006RequestBody()
+    {
+    }
+    
+    public DefineTask_006RequestBody(string taskName, int taskId)
+    {
+        this.taskName = taskName;
+        this.taskId = taskId;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
+public partial class DefineTask_006Response
+{
+    
+    [System.ServiceModel.MessageBodyMemberAttribute(Name="DefineTask_006Response", Namespace="http://tempuri.org/", Order=0)]
+    public DefineTask_006ResponseBody Body;
+    
+    public DefineTask_006Response()
+    {
+    }
+    
+    public DefineTask_006Response(DefineTask_006ResponseBody Body)
+    {
+        this.Body = Body;
+    }
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+[System.Runtime.Serialization.DataContractAttribute(Namespace="")]
+public partial class DefineTask_006ResponseBody
+{
+    
+    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)]
+    public string DefineTaskResult;
+    
+    [System.Runtime.Serialization.DataMemberAttribute(Order=1)]
+    public int taskStatusCode;
+    
+    public DefineTask_006ResponseBody()
+    {
+    }
+    
+    public DefineTask_006ResponseBody(string DefineTaskResult, int taskStatusCode)
+    {
+        this.DefineTaskResult = DefineTaskResult;
+        this.taskStatusCode = taskStatusCode;
+    }
+}
+
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+public interface ImesInterfaceChannel : ImesInterface, System.ServiceModel.IClientChannel
+{
+}
+
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
+public partial class ImesInterfaceClient : System.ServiceModel.ClientBase<ImesInterface>, ImesInterface
+{
+    
+    public ImesInterfaceClient()
+    {
+    }
+    
+    //public ImesInterfaceClient(string endpointConfigurationName) : 
+    //        base(endpointConfigurationName)
+    //{
+    //}
+    
+    //public ImesInterfaceClient(string endpointConfigurationName, string remoteAddress) : 
+    //        base(endpointConfigurationName, remoteAddress)
+    //{
+    //}
+    
+    //public ImesInterfaceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
+    //        base(endpointConfigurationName, remoteAddress)
+    //{
+    //}
+    
+    public ImesInterfaceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
+            base(binding, remoteAddress)
+    {
+    }
+    
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+    PrintHelloResponse ImesInterface.PrintHello(PrintHelloRequest request)
+    {
+        return base.Channel.PrintHello(request);
+    }
+    
+    public string PrintHello()
+    {
+        PrintHelloRequest inValue = new PrintHelloRequest();
+        inValue.Body = new PrintHelloRequestBody();
+        PrintHelloResponse retVal = ((ImesInterface)(this)).PrintHello(inValue);
+        return retVal.Body.PrintHelloResult;
+    }
+    
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+    System.Threading.Tasks.Task<PrintHelloResponse> ImesInterface.PrintHelloAsync(PrintHelloRequest request)
+    {
+        return base.Channel.PrintHelloAsync(request);
+    }
+    
+    public System.Threading.Tasks.Task<PrintHelloResponse> PrintHelloAsync()
+    {
+        PrintHelloRequest inValue = new PrintHelloRequest();
+        inValue.Body = new PrintHelloRequestBody();
+        return ((ImesInterface)(this)).PrintHelloAsync(inValue);
+    }
+    
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+    DefineTask_001Response ImesInterface.DefineTask_001(DefineTask_001Request request)
+    {
+        return base.Channel.DefineTask_001(request);
+    }
+    
+    public string DefineTask_001(string taskName, int taskId, out int taskStatusCode)
+    {
+        DefineTask_001Request inValue = new DefineTask_001Request();
+        inValue.Body = new DefineTask_001RequestBody();
+        inValue.Body.taskName = taskName;
+        inValue.Body.taskId = taskId;
+        DefineTask_001Response retVal = ((ImesInterface)(this)).DefineTask_001(inValue);
+        taskStatusCode = retVal.Body.taskStatusCode;
+        return retVal.Body.DefineTaskResult;
+    }
+    
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+    System.Threading.Tasks.Task<DefineTask_001Response> ImesInterface.DefineTask_001Async(DefineTask_001Request request)
+    {
+        return base.Channel.DefineTask_001Async(request);
+    }
+    
+    public System.Threading.Tasks.Task<DefineTask_001Response> DefineTask_001Async(string taskName, int taskId)
+    {
+        DefineTask_001Request inValue = new DefineTask_001Request();
+        inValue.Body = new DefineTask_001RequestBody();
+        inValue.Body.taskName = taskName;
+        inValue.Body.taskId = taskId;
+        return ((ImesInterface)(this)).DefineTask_001Async(inValue);
+    }
+    
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+    DefineTask_006Response ImesInterface.DefineTask_006(DefineTask_006Request request)
+    {
+        return base.Channel.DefineTask_006(request);
+    }
+    
+    public string DefineTask_006(string taskName, int taskId, out int taskStatusCode)
+    {
+        DefineTask_006Request inValue = new DefineTask_006Request();
+        inValue.Body = new DefineTask_006RequestBody();
+        inValue.Body.taskName = taskName;
+        inValue.Body.taskId = taskId;
+        DefineTask_006Response retVal = ((ImesInterface)(this)).DefineTask_006(inValue);
+        taskStatusCode = retVal.Body.taskStatusCode;
+        return retVal.Body.DefineTaskResult;
+    }
+    
+    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+    System.Threading.Tasks.Task<DefineTask_006Response> ImesInterface.DefineTask_006Async(DefineTask_006Request request)
+    {
+        return base.Channel.DefineTask_006Async(request);
+    }
+    
+    public System.Threading.Tasks.Task<DefineTask_006Response> DefineTask_006Async(string taskName, int taskId)
+    {
+        DefineTask_006Request inValue = new DefineTask_006Request();
+        inValue.Body = new DefineTask_006RequestBody();
+        inValue.Body.taskName = taskName;
+        inValue.Body.taskId = taskId;
+        return ((ImesInterface)(this)).DefineTask_006Async(inValue);
+    }
+}
diff --git a/Controllers/AGV/app.config b/Controllers/AGV/app.config
new file mode 100644
index 0000000..7d4c988
--- /dev/null
+++ b/Controllers/AGV/app.config
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+    <system.serviceModel>
+        <bindings>
+            <basicHttpBinding>
+                <binding name="BasicHttpBinding_ImesInterface" />
+            </basicHttpBinding>
+        </bindings>
+        <client>
+            <endpoint address="http://192.168.35.251:8000/MesGet" binding="basicHttpBinding"
+                bindingConfiguration="BasicHttpBinding_ImesInterface" contract="ImesInterface"
+                name="BasicHttpBinding_ImesInterface" />
+        </client>
+    </system.serviceModel>
+</configuration>
\ No newline at end of file
diff --git a/Controllers/Warehouse/MesCgthSqController.cs b/Controllers/Warehouse/MesCgthSqController.cs
index f8f491d..cc451a7 100644
--- a/Controllers/Warehouse/MesCgthSqController.cs
+++ b/Controllers/Warehouse/MesCgthSqController.cs
@@ -66,7 +66,7 @@
 
     //ScanCode
     /// <summary>
-    ///     鑾峰彇鎵�鏈夊凡缁忓鏍哥殑鐢宠鍗�
+    ///    閲囪喘閫�璐�
     /// </summary>
     /// <returns></returns>
     [HttpPost("ScanCode")]
@@ -98,6 +98,59 @@
         }
     }
 
+    //ScanCode
+    /// <summary>
+    ///    閲囪喘楠岄��
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("ScanCgyt")]
+    public ResponseResult ScanCgyt(dynamic query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = m.ScanCgyt(query);
+            resultInfos.YtItem = m.getYtItem(resultInfos.tbBillList.ytdh);
+            resultInfos.YtBarInfo = m.getYtBarInfo(resultInfos.tbBillList.ytdh);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+
+    //ScanCode
+    /// <summary>
+    ///    閲囪喘閫�璐у垹闄�
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("deleteCgyt")]
+    public ResponseResult deleteCgyt(dynamic query)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.tbBillList = m.deleteCgyt(query);
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
     [HttpPost("ScanCodeCF")]
     public ResponseResult ScanCodeCF(WarehouseQuery query)
     {
diff --git a/NewPdaSqlServer.csproj b/NewPdaSqlServer.csproj
index 80092b3..64dfbc8 100644
--- a/NewPdaSqlServer.csproj
+++ b/NewPdaSqlServer.csproj
@@ -20,6 +20,7 @@
         <PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
         <PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
         <PackageReference Include="System.Security.Cryptography.Xml" Version="9.0.4" />
+        <PackageReference Include="System.ServiceModel.Http" Version="8.1.2" />
     </ItemGroup>
 
     <ItemGroup>
diff --git a/service/Warehouse/MesBarCFManager.cs b/service/Warehouse/MesBarCFManager.cs
index 01f0ebd..7a5da90 100644
--- a/service/Warehouse/MesBarCFManager.cs
+++ b/service/Warehouse/MesBarCFManager.cs
@@ -34,6 +34,13 @@
 
         if(KcInfo.Count > 0) throw new Exception("璇ユ潯鐮佸凡鍏ュ簱涓嶈兘杩涜鍏ュ簱鍓嶆媶鍒嗭紒");
 
+
+        //var sql3 = @"SELECT 1 FROM MES_INV_ITEM_CGYT_C_DETAILS WHERE ITEM_BARCODE =@barcode";
+
+        //var YtInfo = Db.Ado.SqlQuery<dynamic>(sql3, sqlParams);
+
+        //if (YtInfo.Count > 0) throw new Exception("璇ユ潯鐮佸凡鎵弿閫�鏂欎笉鑳借繘琛屽叆搴撳墠鎷嗗垎锛�");
+
         var sql2 = @"SELECT ITEM_ID,QUANTITY FROM MES_INV_ITEM_BARCODES WHERE ITEM_BARCODE =@barcode ";
 
         var barInfo = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).FirstOrDefault();
diff --git a/service/Warehouse/MesCgthSqManager.cs b/service/Warehouse/MesCgthSqManager.cs
index dbb8747..4c92478 100644
--- a/service/Warehouse/MesCgthSqManager.cs
+++ b/service/Warehouse/MesCgthSqManager.cs
@@ -6,6 +6,7 @@
 using NewPdaSqlServer.entity;
 using NewPdaSqlServer.entity.Base;
 using SqlSugar;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
 
 namespace NewPdaSqlServer.service.Warehouse;
 
@@ -224,4 +225,164 @@
             }
         }
     }
+
+
+    /// <summary>
+    /// 閲囪喘鎵爜楠岄��
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    /// <exception cref="ArgumentNullException"></exception>
+    /// <exception cref="ArgumentException"></exception>
+    /// <exception cref="Exception"></exception>
+    public dynamic ScanCgyt(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null");
+
+        // 2. 浣跨敤 string.IsNullOrEmpty 鐩存帴鍒ゆ柇瀛楃涓插睘鎬э紙閬垮厤 NullReferenceException锛�
+        if (string.IsNullOrEmpty(query.userName?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName));
+
+        if (string.IsNullOrEmpty(query.barcode?.ToString()))
+            throw new ArgumentException("閲囪喘鐗╂枡鏉$爜涓嶅厑璁镐负绌�", nameof(query.barcode));
+
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_scan_CGYT", conn))
+            {
+                cmd.CommandType = CommandType.StoredProcedure;
+                var parameters = new SqlParameter[]
+                {
+                    new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName },
+                    new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = query.barcode },
+                    new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+                    new("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output },
+                    new("@po_ygdh", SqlDbType.NVarChar, 200) { Direction = ParameterDirection.Output }
+                };
+
+                cmd.Parameters.AddRange(parameters);
+                conn.Open();
+                cmd.ExecuteNonQuery();
+
+                var result = new
+                {
+                    result = parameters[3].Value.ToString(),
+                    barcode = query.barcode,
+                    ytdh = parameters[4].Value.ToString(),
+                    msg = parameters[2].Value.ToString()
+                };
+
+                if (result.result == "-1")
+                    throw new Exception(parameters[2].Value.ToString());
+
+                return result;
+            }
+        }
+    }
+
+    /// <summary>
+    /// 鍒犻櫎楠岄��鍗�
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    /// <exception cref="ArgumentNullException"></exception>
+    /// <exception cref="ArgumentException"></exception>
+    /// <exception cref="Exception"></exception>
+    public dynamic deleteCgyt(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null");
+
+        // 2. 浣跨敤 string.IsNullOrEmpty 鐩存帴鍒ゆ柇瀛楃涓插睘鎬э紙閬垮厤 NullReferenceException锛�
+        if (string.IsNullOrEmpty(query.userName?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName));
+
+        if (string.IsNullOrEmpty(query.ytdh?.ToString()))
+            throw new ArgumentException("杩芥函鐮佷笉鍏佽涓虹┖", nameof(query.ytdh));
+
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_delete_CGYT", conn))
+            {
+                cmd.CommandType = CommandType.StoredProcedure;
+                var parameters = new SqlParameter[]
+                {
+                    new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName },
+                    new("@pi_ytdh", SqlDbType.NVarChar, 100) { Value = query.ytdh },
+                    new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+                    new("@po_outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }
+                };
+
+                cmd.Parameters.AddRange(parameters);
+                conn.Open();
+                cmd.ExecuteNonQuery();
+
+                var result = new
+                {
+                    result = parameters[3].Value.ToString(),
+                    msg = parameters[2].Value.ToString(),
+                };
+
+                if (result.result == "-1")
+                    throw new Exception(parameters[2].Value.ToString());
+
+                return result;
+            }
+        }
+    }
+
+    /// <summary>
+    /// 鑾峰彇楠岄��鍗曞凡鎵墿鏂欎俊鎭�
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    public dynamic getYtItem(string ytdh)
+    {
+        if (string.IsNullOrEmpty(ytdh?.ToString()))
+            throw new ArgumentException("楠岄��鍗曞彿涓嶅厑璁镐负绌�", nameof(ytdh));
+
+        var sqlParams = new List<SugarParameter> { new("@ytdh", ytdh) };
+
+        var sql1 = @"SELECT C.item_id,C.item_no,C.item_name,C.item_model,A.quantity
+FROM MES_INV_ITEM_CGYT_ITEMS A
+         LEFT JOIN MES_INV_ITEM_CGYT B ON A.item_cgyt_id = B.GUID
+        LEFT JOIN MES_ITEMS C ON A.item_id = C.item_id
+WHERE B.item_cgyt_no = @ytdh";
+
+        var YtItem = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams);
+
+        //if (YtItem.Count < 1)
+        //{
+        //    throw new Exception($"璇ラ獙閫�鍗曞彿{ytdh}鐗╂枡鏄庣粏涓嶅瓨鍦紒");
+        //}
+
+        return YtItem;
+    }
+
+    /// <summary>
+    /// 鑾峰彇楠岄��鍗曞凡鎵潯鐮佷俊鎭�
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    public dynamic getYtBarInfo(string ytdh)
+    {
+        if (string.IsNullOrEmpty(ytdh?.ToString()))
+            throw new ArgumentException("楠岄��鍗曞彿涓嶅厑璁镐负绌�", nameof(ytdh));
+
+        var sqlParams = new List<SugarParameter> { new("@ytdh", ytdh) };
+
+        var sql1 = @"SELECT C.item_id,C.item_no,C.item_name,C.item_model,A.quantity,A.ITEM_BARCODE
+FROM MES_INV_ITEM_CGYT_C_DETAILS A
+         LEFT JOIN MES_INV_ITEM_CGYT B ON A.item_cgyt_id = B.GUID
+        LEFT JOIN MES_ITEMS C ON A.item_id = C.item_id
+WHERE B.item_cgyt_no = @ytdh";
+
+        var YtBarInfo = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams);
+
+        //if (YtBarInfo.Count < 1)
+        //{
+        //    throw new Exception($"璇ラ獙閫�鍗曞彿{ytdh}浠栦滑涓嶅瓨鍦紒");
+        //}
+
+        return YtBarInfo;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3