From e4df994169c2fac14b7a2b5357c795a344410776 Mon Sep 17 00:00:00 2001 From: H Vs Date: Wed, 28 Feb 2024 11:45:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=88=B0=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TcpServer/Handler/RegisterHandler.cs | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs b/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs index 624ce0a..a941416 100644 --- a/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs +++ b/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs @@ -219,12 +219,23 @@ namespace NearCardAttendance.Service.TcpServer.Handler /// private async Task HandleSignRecsAsync(ProtocolParser parser, IChannel channel) { - ProtocolWrapper stdtSignRecsWrapper = new(parser.FuncNo, parser.SeqNo, "1"); - await SendToTcpClientAsync(stdtSignRecsWrapper, channel); + ProtocolWrapper stdtSignRecsWrapper = new(parser.FuncNo, parser.SeqNo, "1"); + await SendToTcpClientAsync(stdtSignRecsWrapper, channel); + var deviceId = parser.Data.Substring(0, 18).TrimEnd(); + var cardId= parser.Data.Substring(18,18).TrimEnd(); + var studentId = parser.Data.Substring(36,18).TrimEnd(); + var startTime = parser.Data.Substring(54, 14).TrimEnd(); // Push card attendance information to third-party platform - //var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"; - //await _httpHelper.HttpToPostAsync(url, new object()); + var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"; + var data = new + { + attendanceStatus = 2, //考勤状态: 0.进 1.出 2.未知 + attendanceTime = DateTime.TryParse(startTime, out DateTime time) ? time.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + imei = deviceId + }; + var res=await _httpHelper.HttpToPostAsync(url, data); + _logger.LogInformation($"{nameof(HandleSignRecsAsync)} 推送结果,{res}"); } /// @@ -239,8 +250,22 @@ namespace NearCardAttendance.Service.TcpServer.Handler ProtocolWrapper stdtSchoolRecsWrapper = new(parser.FuncNo, parser.SeqNo, "1"); await SendToTcpClientAsync(stdtSchoolRecsWrapper, channel); - //var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"; - //await _httpHelper.HttpToPostAsync(url, new object()); + var deviceId = parser.Data.Substring(0, 18).TrimEnd(); + var cardId = parser.Data.Substring(18, 18).TrimEnd(); + var studentId = parser.Data.Substring(36, 18).TrimEnd(); + var startTime = parser.Data.Substring(54, 14).TrimEnd(); + var optType = parser.Data.Substring(68, 1).TrimEnd(); + + var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"; + + var data = new + { + attendanceStatus = int.TryParse(optType,out int type) ? type : 0, + attendanceTime = DateTime.TryParse(startTime, out DateTime time) ? time.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + imei = deviceId + }; + var res = await _httpHelper.HttpToPostAsync(url, data); + _logger.LogInformation($"{nameof(HandleStdtSchoolRecsAsync)} 推送结果,{res}"); } } }