2025-09-19 11:36:17 +08:00
|
|
|
|
using JiShe.ServicePro;
|
|
|
|
|
|
using JiShe.ServicePro.ApacheIoTDB.Provider.Options;
|
|
|
|
|
|
using JiShe.ServicePro.Consts;
|
|
|
|
|
|
using JiShe.ServicePro.Core;
|
|
|
|
|
|
using JiShe.ServicePro.Dto;
|
|
|
|
|
|
using JiShe.ServicePro.Enums;
|
2025-05-27 16:16:07 +08:00
|
|
|
|
using JiShe.ServicePro.FreeRedisProvider;
|
|
|
|
|
|
using JiShe.ServicePro.FreeSqlProvider;
|
2025-09-19 11:36:17 +08:00
|
|
|
|
using JiShe.ServicePro.IoTDBManagement.TableModels;
|
|
|
|
|
|
using Volo.Abp;
|
2025-05-27 16:16:07 +08:00
|
|
|
|
|
2025-05-27 14:27:50 +08:00
|
|
|
|
namespace JiShe.IoT
|
|
|
|
|
|
{
|
|
|
|
|
|
/* Inherit your application services from this class.
|
|
|
|
|
|
*/
|
|
|
|
|
|
public abstract class IoTAppService : ApplicationService
|
|
|
|
|
|
{
|
2025-05-27 16:16:07 +08:00
|
|
|
|
protected IFreeSqlProvider FreeSqlDbContext => LazyServiceProvider.LazyGetRequiredService<IFreeSqlProvider>();
|
2025-06-04 17:09:21 +08:00
|
|
|
|
protected IFreeRedisProvider RedisProvider => LazyServiceProvider.LazyGetRequiredService<IFreeRedisProvider>();
|
2025-05-27 16:16:07 +08:00
|
|
|
|
|
2025-05-27 14:27:50 +08:00
|
|
|
|
protected IoTAppService()
|
|
|
|
|
|
{
|
|
|
|
|
|
LocalizationResource = typeof(IoTResource);
|
|
|
|
|
|
}
|
2025-09-19 11:36:17 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><>ȡ<EFBFBD>豸ң<E8B1B8><D2A3>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="iotDBOptions">IoTDBOptions</param>
|
|
|
|
|
|
/// <param name="input"><3E><><EFBFBD><EFBFBD>ԭʼ<D4AD><CABC><EFBFBD><EFBFBD></param>
|
|
|
|
|
|
/// <param name="deviceInfo"><3E>豸<EFBFBD><E8B1B8>Ϣ</param>
|
|
|
|
|
|
/// <param name="messageBody"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
|
|
|
protected DeviceTelemetryPacketTaskInfo GetDeviceTelemetryPacketTaskInfo(IoTDBOptions iotDBOptions, OpenApiRequest input, DeviceCacheInfos deviceInfo,string messageBody)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (iotDBOptions == null || string.IsNullOrWhiteSpace(iotDBOptions.DataBaseName) || input == null || deviceInfo == null || string.IsNullOrWhiteSpace(messageBody))
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new UserFriendlyException($"<22>豸ң<E8B1B8><D2A3>ָ<EFBFBD><EFBFBD><EEB4B4>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>쳣<EFBFBD><ECB3A3>");
|
|
|
|
|
|
}
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ݣ<EFBFBD><DDA3>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
|
|
|
|
|
ReceiveCommandInfoDto commandIssueInfo = input.Message.Deserialize<ReceiveCommandInfoDto>();
|
|
|
|
|
|
|
|
|
|
|
|
var oneNETIssueMessageEntity = new DeviceTelemetryPacketTaskInfo()
|
|
|
|
|
|
{
|
|
|
|
|
|
DataBaseName = iotDBOptions.DataBaseName,
|
|
|
|
|
|
DeviceType = $"{commandIssueInfo.DeviceType}",
|
|
|
|
|
|
DeviceAddress = commandIssueInfo.DeviceAddress,
|
|
|
|
|
|
IssueRawMessage = input.Serialize(),
|
|
|
|
|
|
IoTDataType = IoTDBDataTypeConst.Command,
|
|
|
|
|
|
TelemetryType = (int)commandIssueInfo.TelemetryType,
|
|
|
|
|
|
TelemetrySource = (int)commandIssueInfo.SourceType,
|
|
|
|
|
|
IoTPlatform = (int)commandIssueInfo.IoTPlatform,
|
|
|
|
|
|
IoTPlatformProductId = deviceInfo.IoTPlatformProductId,
|
|
|
|
|
|
IoTPlatformDeviceOpenInfo = deviceInfo.IoTPlatformDeviceOpenInfo,
|
|
|
|
|
|
IoTPlatformAccountId = deviceInfo.IoTPlatformAccountId,
|
|
|
|
|
|
AccountPhoneNumber = deviceInfo.AccountPhoneNumber,
|
|
|
|
|
|
IoTPlatformProductName = deviceInfo.IoTPlatformProductName,
|
|
|
|
|
|
IssuePayload = messageBody,
|
|
|
|
|
|
RetryCount = 0,
|
|
|
|
|
|
IssueStatus = (int)DeviceCommandIssueStatusEnum.Unprocessed
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return oneNETIssueMessageEntity;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-27 14:27:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|