南骏 池
3 天以前 ed670b6b4a44a11060a7527809c84ff4c32ba6a6
1.AGV接口开发
2.采购扫描验退
已添加3个文件
已修改4个文件
859 ■■■■■ 文件已修改
Controllers/AGV/AgvApiController.cs 218 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Controllers/AGV/MesClient.cs 402 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Controllers/AGV/app.config 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Controllers/Warehouse/MesCgthSqController.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
NewPdaSqlServer.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/Warehouse/MesBarCFManager.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/Warehouse/MesCgthSqManager.cs 161 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
}
Controllers/AGV/MesClient.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,402 @@
//------------------------------------------------------------------------------
// <auto-generated>
//     æ­¤ä»£ç ç”±å·¥å…·ç”Ÿæˆã€‚
//     è¿è¡Œæ—¶ç‰ˆæœ¬:4.0.30319.42000
//
//     å¯¹æ­¤æ–‡ä»¶çš„æ›´æ”¹å¯èƒ½ä¼šå¯¼è‡´ä¸æ­£ç¡®çš„行为,并且如果
//     é‡æ–°ç”Ÿæˆä»£ç ï¼Œè¿™äº›æ›´æ”¹å°†ä¼šä¸¢å¤±ã€‚
// </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);
    }
}
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>
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)
    {
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>
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();
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;
    }
}