diff --git a/NearCardAttendance.Service/NearCardAttendance.Service.csproj b/NearCardAttendance.Service/NearCardAttendance.Service.csproj
index e704fc3..957e400 100644
--- a/NearCardAttendance.Service/NearCardAttendance.Service.csproj
+++ b/NearCardAttendance.Service/NearCardAttendance.Service.csproj
@@ -15,6 +15,7 @@
+
diff --git a/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs b/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs
index 8a6ee56..ce0a3eb 100644
--- a/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs
+++ b/NearCardAttendance.Service/TcpServer/Handler/RegisterHandler.cs
@@ -13,6 +13,11 @@ using System.Threading.Channels;
using System.Threading.Tasks;
using NearCardAttendance.Model;
using Microsoft.Extensions.Options;
+using TelpoDataService.Util.Entities.GpsCard;
+using TelpoDataService.Util;
+using TelpoDataService.Util.Clients;
+using TelpoDataService.Util.Models;
+using TelpoDataService.Util.QueryObjects;
namespace NearCardAttendance.Service.TcpServer.Handler
{
@@ -22,15 +27,17 @@ namespace NearCardAttendance.Service.TcpServer.Handler
private readonly HttpHelper _httpHelper = default!;
private readonly IDisposable _loggerScope = default!;
private readonly ServiceConfig _configService;
+ private readonly GpsCardAccessorClient _deviceConfigApiClient;
//private readonly TcpClientsManager _managerTcpClients;
//private readonly ScheduleResendManager _managerScheduleResend;
- public RegisterHandler(ILogger logger,HttpHelper httpHelper, IOptions configService)
+ public RegisterHandler(ILogger logger, GpsCardAccessorClient deviceConfigApiClient,HttpHelper httpHelper, IOptions configService)
{
_logger = logger;
_httpHelper = httpHelper;
_configService = configService.Value;
+ _deviceConfigApiClient= deviceConfigApiClient;
}
public override void ChannelActive(IChannelHandlerContext context)
@@ -232,15 +239,49 @@ namespace NearCardAttendance.Service.TcpServer.Handler
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";
- var url = _configService.XinHuaLeYuUrl;
- 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)} 推送 {JsonConvert.SerializeObject(data)} 结果,{res}");
+
+ #region IC卡转换为IMEI
+ var config= await _deviceConfigApiClient.GetFirstAsync(new GeneralParam
+ {
+ Filters = new List
+ {
+ new QueryFilterCondition
+ {
+ Key=nameof(GpsDeviceConfig.IdNumber),
+ Value=cardId,
+ ValueType=QueryValueTypeEnum.String,
+ Operator=QueryOperatorEnum.Equal
+ }
+ },
+ OrderBys=new List
+ {
+ new OrderByCondition
+ {
+ IsDesc=true,
+ Key=nameof(GpsDeviceConfig.LastUpdate),
+ }
+ }
+ }, new RequestHeader { RequestId = parser.SeqNo }).ConfigureAwait(false);
+
+ #endregion
+
+ if (config!=null)
+ {
+ var url = _configService.XinHuaLeYuUrl;
+ 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 = config.Imei
+ };
+ var res = await _httpHelper.HttpToPostAsync(url, data);
+ _logger.LogInformation($"{nameof(HandleSignRecsAsync)} 推送 {JsonConvert.SerializeObject(data)} 结果,{res}");
+ }
+ else
+ {
+ _logger.LogInformation("找不到IC卡转换为IMEI的对应关系");
+ }
+
}
///
@@ -260,17 +301,47 @@ namespace NearCardAttendance.Service.TcpServer.Handler
var studentId = parser.Data.Substring(36, 18).TrimEnd();
var startTime = parser.Data.Substring(54, 14).TrimEnd();
var optType = parser.Data.Substring(68, 1).TrimEnd();
+ #region IC卡转换为IMEI
+ var config = await _deviceConfigApiClient.GetFirstAsync(new GeneralParam
+ {
+ Filters = new List
+ {
+ new QueryFilterCondition
+ {
+ Key=nameof(GpsDeviceConfig.IdNumber),
+ Value=cardId,
+ ValueType=QueryValueTypeEnum.String,
+ Operator=QueryOperatorEnum.Equal
+ }
+ },
+ OrderBys = new List
+ {
+ new OrderByCondition
+ {
+ IsDesc=true,
+ Key=nameof(GpsDeviceConfig.LastUpdate),
+ }
+ }
+ }, new RequestHeader { RequestId = parser.SeqNo }).ConfigureAwait(false);
- //var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
- var url = _configService.XinHuaLeYuUrl;
- var data = new
+ #endregion
+ if (config != null)
+ {
+ //var url = "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord";
+ var url = _configService.XinHuaLeYuUrl;
+ 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 = config.Imei
+ };
+ var res = await _httpHelper.HttpToPostAsync(url, data);
+ _logger.LogInformation($"{nameof(HandleStdtSchoolRecsAsync)} 推送 {JsonConvert.SerializeObject(data)} 结果,{res}");
+ }
+ else
{
- 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)} 推送 {JsonConvert.SerializeObject(data)} 结果,{res}");
+ _logger.LogInformation("找不到IC卡转换为IMEI的对应关系");
+ }
}
}
}
diff --git a/NearCardAttendance.TcpServer/Program.cs b/NearCardAttendance.TcpServer/Program.cs
index 43d9f84..143bc5c 100644
--- a/NearCardAttendance.TcpServer/Program.cs
+++ b/NearCardAttendance.TcpServer/Program.cs
@@ -13,6 +13,7 @@ using NearCardAttendance.TcpServer.Config;
using Serilog;
using NearCardAttendance.Model;
using System.Text;
+using TelpoDataService.Util.Clients;
namespace NearCardAttendance.TcpServer
{
@@ -52,7 +53,10 @@ namespace NearCardAttendance.TcpServer
.UseSerilog()
.ConfigureServices((hostContext, services) => {
var configuration = hostContext.Configuration;
-
+ services.AddTelpoDataServices(opt =>
+ {
+ opt.TelpoDataUrl = configuration["ServiceConfig:TelpoDataUrl"];
+ });
#region 配置信息
services
.Configure(configuration.GetSection("ServiceConfig"))
diff --git a/NearCardAttendance.TcpServer/appsettings.debug.json b/NearCardAttendance.TcpServer/appsettings.debug.json
index 0f39240..f313f1b 100644
--- a/NearCardAttendance.TcpServer/appsettings.debug.json
+++ b/NearCardAttendance.TcpServer/appsettings.debug.json
@@ -1,6 +1,7 @@
{
"AllowedHosts": "*",
"ServiceConfig": {
- "XinHuaLeYuUrl": "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"
+ "XinHuaLeYuUrl": "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord",
+ "TelpoDataUrl": "https://ai.ssjlai.com/data"
}
}
diff --git a/NearCardAttendance.TcpServer/appsettings.test.json b/NearCardAttendance.TcpServer/appsettings.test.json
index 0f39240..f313f1b 100644
--- a/NearCardAttendance.TcpServer/appsettings.test.json
+++ b/NearCardAttendance.TcpServer/appsettings.test.json
@@ -1,6 +1,7 @@
{
"AllowedHosts": "*",
"ServiceConfig": {
- "XinHuaLeYuUrl": "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord"
+ "XinHuaLeYuUrl": "https://midplat.xinhualeyu.com/dev-api/user/electronicCardAttendance/receiveTbAttendanceRecord",
+ "TelpoDataUrl": "https://ai.ssjlai.com/data"
}
}