From 6dae2517aa69e7a81e87b8cc2bcb63f401fa77dd Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期四, 21 八月 2025 13:46:51 +0800 Subject: [PATCH] 1.AGV调用新增日志。 --- Controllers/AGV/AgvApiController.cs | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 216 insertions(+), 10 deletions(-) diff --git a/Controllers/AGV/AgvApiController.cs b/Controllers/AGV/AgvApiController.cs index e9776fa..e0e813b 100644 --- a/Controllers/AGV/AgvApiController.cs +++ b/Controllers/AGV/AgvApiController.cs @@ -7,6 +7,9 @@ using Newtonsoft.Json.Linq; using System.ServiceModel; using System.IO; +using NewPdaSqlServer.Dto.Warehouse; +using NewPdaSqlServer.DB; +using Newtonsoft.Json; namespace NewPdaSqlServer.Controllers.AGV; @@ -57,8 +60,14 @@ //绔嬪簱閫佹 [HttpPost("DefineTask_001")] - public ResponseResult DefineTask_001(dynamic queryObj) + public ResponseResult DefineTask_001(DefineTask001Dto dto) { + string _requestJson = string.Empty; + dynamic _responseData = new System.Dynamic.ExpandoObject(); + string _executeTimestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + int sendStatus = 0; + string _logMessage = "銆怉GV銆戠珛搴撻�佹"; + try { var binding = new BasicHttpBinding @@ -68,11 +77,43 @@ }; var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet"); + //var endpoint = new EndpointAddress("http://192.168.32.17: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); + //string result = channel.DefineTask_001("GS2025070700001","TEST.01","AGV娴嬭瘯鐗╂枡鍚嶇О", "AGV娴嬭瘯鐗╂枡瑙勬牸",100,"鍙�",1); + string result = channel.DefineTask_001( + dto.MesId, + dto.MatId, + dto.MatName, + dto.MatStandard, + dto.MatNumber, + dto.MatUnit, + dto.Postition); + ((IClientChannel)channel).Close(); + + // 璁板綍璇锋眰鎶ユ枃 + _requestJson = JsonConvert.SerializeObject(dto); + + _responseData = result; + sendStatus = 1; + + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage, + orderNo: dto.MesId, + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: sendStatus, + executeTime: _executeTimestamp + ); return new ResponseResult { @@ -83,14 +124,35 @@ } catch (Exception ex) { + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage + $"绯荤粺寮傚父锛歿ex.Message}", + orderNo: dto.MesId, + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: 0, + executeTime: _executeTimestamp + ); return ResponseResult.ResponseError(ex); } } //绔嬪簱妫�楠� [HttpPost("DefineTask_002")] - public ResponseResult DefineTask_002(dynamic queryObj) + public ResponseResult DefineTask_002(DefineTask002Dto dto) { + string _requestJson = string.Empty; + dynamic _responseData = new System.Dynamic.ExpandoObject(); + string _executeTimestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + int sendStatus = 0; + string _logMessage = "銆怉GV銆戠珛搴撴楠�"; + try { var binding = new BasicHttpBinding @@ -100,11 +162,38 @@ }; var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet"); + //var endpoint = new EndpointAddress("http://192.168.32.17:8000/MesGet"); var factory = new ChannelFactory<IImesInterface>(binding, endpoint); var channel = factory.CreateChannel(); - string result = channel.DefineTask_002("GS2025070900010", "鍚堟牸"); + //string result = channel.DefineTask_002("GS2025070900010", "鍚堟牸"); + string result = channel.DefineTask_002( + dto.MesId, + dto.MatStatus); + ((IClientChannel)channel).Close(); + + // 璁板綍璇锋眰鎶ユ枃 + _requestJson = JsonConvert.SerializeObject(dto); + + _responseData = result; + sendStatus = 1; + + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage, + orderNo: dto.MesId, + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: sendStatus, + executeTime: _executeTimestamp + ); return new ResponseResult { @@ -115,14 +204,35 @@ } catch (Exception ex) { + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage + $"绯荤粺寮傚父锛歿ex.Message}", + orderNo: dto.MesId, + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: 0, + executeTime: _executeTimestamp + ); + return ResponseResult.ResponseError(ex); } } //绔嬪簱鍛煎彨 [HttpPost("DefineTask_005")] - public ResponseResult DefineTask_005(dynamic queryObj) + public ResponseResult DefineTask_005(DefineTask005Dto dto) { + string _requestJson = string.Empty; + dynamic _responseData = new System.Dynamic.ExpandoObject(); + string _executeTimestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + int sendStatus = 0; + string _logMessage = "銆怉GV銆戠珛搴撳懠鍙�"; try { var binding = new BasicHttpBinding @@ -132,11 +242,37 @@ }; var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet"); + //var endpoint = new EndpointAddress("http://192.168.32.17:8000/MesGet"); var factory = new ChannelFactory<IImesInterface>(binding, endpoint); var channel = factory.CreateChannel(); - string result = channel.DefineTask_005(); + //string result = channel.DefineTask_005(2); + string result = channel.DefineTask_005( + dto.Postition); ((IClientChannel)channel).Close(); + + // 璁板綍璇锋眰鎶ユ枃 + _requestJson = JsonConvert.SerializeObject(dto); + + _responseData = result; + sendStatus = 1; + + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage, + orderNo: "", + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: sendStatus, + executeTime: _executeTimestamp + ); + return new ResponseResult { @@ -147,6 +283,22 @@ } catch (Exception ex) { + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage + $"绯荤粺寮傚父锛歿ex.Message}", + orderNo: "", + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: 0, + executeTime: _executeTimestamp + ); + return ResponseResult.ResponseError(ex); } } @@ -154,8 +306,14 @@ //绔嬪簱鍏ュ簱 [HttpPost("DefineTask_006")] - public ResponseResult DefineTask_006(dynamic queryObj) + public ResponseResult DefineTask_006(DefineTask006Dto dto) { + string _requestJson = string.Empty; + dynamic _responseData = new System.Dynamic.ExpandoObject(); + string _executeTimestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + int sendStatus = 0; + string _logMessage = "銆怉GV銆戠珛搴撳叆搴�"; + try { var binding = new BasicHttpBinding @@ -165,11 +323,43 @@ }; var endpoint = new EndpointAddress("http://192.168.35.251:8000/MesGet"); + //var endpoint = new EndpointAddress("http://192.168.32.17: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); + //string result = channel.DefineTask_006("C2025070400040", "2.02.51.463", "绠$嚎楗按鏈�", "C638-1HA(涓囧拰VGX-SR-1A-XM鐧�)", 48, "鍙�", 4); + string result = channel.DefineTask_006( + dto.MesId, + dto.MatId, + dto.MatName, + dto.MatStandard, + dto.MatNumber, + dto.MatUnit, + dto.Postition); ((IClientChannel)channel).Close(); + + // 璁板綍璇锋眰鎶ユ枃 + _requestJson = JsonConvert.SerializeObject(dto); + + _responseData = result; + sendStatus = 1; + + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage, + orderNo: dto.MesId, + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: sendStatus, + executeTime: _executeTimestamp + ); + return new ResponseResult { @@ -180,6 +370,22 @@ } catch (Exception ex) { + + var logService = new LogService(); + logService.CreateLogI( + db: null, + edtUserGuid: Guid.Parse("11111111-1111-1111-1111-111111111111"), + abtGuid: null, + abtTable: "AGV_TASK", + detail: _logMessage + $"绯荤粺寮傚父锛歿ex.Message}", + orderNo: dto.MesId, + sendJson: _requestJson, + rtnJson: JsonConvert.SerializeObject(_responseData), + xkyBeginTime: null, + xkyEndTime: null, + sendStatus: 0, + executeTime: _executeTimestamp + ); return ResponseResult.ResponseError(ex); } } @@ -209,10 +415,10 @@ //绔嬪簱鍛煎彨 [OperationContract(Action = "http://tempuri.org/ImesInterface/DefineTask_005", ReplyAction = "http://tempuri.org/ImesInterface/DefineTask_005Response")] - string DefineTask_005(); + string DefineTask_005(int Postition); //绔嬪簱鍏ュ簱 [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 +} -- Gitblit v1.9.3