diff --git a/Sln.Imm.Daemon.Cache/BaseDeviceInfoCacheService.cs b/Sln.Imm.Daemon.Cache/BaseDeviceInfoCacheService.cs index d23ad15..201dac8 100644 --- a/Sln.Imm.Daemon.Cache/BaseDeviceInfoCacheService.cs +++ b/Sln.Imm.Daemon.Cache/BaseDeviceInfoCacheService.cs @@ -55,15 +55,15 @@ public class BaseDeviceInfoCacheService var cachedValue = await _fusionCache.GetOrDefaultAsync>(key).ConfigureAwait(false); if (cachedValue != null) { - _logger.Info($"通过Cache获取数据:{cachedValue.Count};条"); + _logger.Info($"通过Cache获取设备数据:{cachedValue.Count};条"); return cachedValue; } else { - var value = _service.Query(); + var value = _service.GetDeviceInfosByNavigate(); //将值存入缓存,设置过期时间等 - await _fusionCache.SetAsync(key, value, TimeSpan.FromSeconds(5)).ConfigureAwait(false); - _logger.Info($"通过ORM获取数据:{value.Count};条"); + await _fusionCache.SetAsync(key, value, TimeSpan.FromMinutes(5)).ConfigureAwait(false); + _logger.Info($"通过ORM获取设备数据:{value.Count};条"); return value; } } @@ -74,7 +74,7 @@ public class BaseDeviceInfoCacheService if (isRes) { - var value = _service.Query(); + var value = _service.GetDeviceInfosByNavigate(); await _fusionCache.SetAsync(key, value, TimeSpan.FromSeconds(5)).ConfigureAwait(false); } diff --git a/Sln.Imm.Daemon.Common/StringChange.cs b/Sln.Imm.Daemon.Common/StringChange.cs index 6423659..6b46bac 100644 --- a/Sln.Imm.Daemon.Common/StringChange.cs +++ b/Sln.Imm.Daemon.Common/StringChange.cs @@ -1,25 +1,25 @@ #region << 版 本 注 释 >> /*-------------------------------------------------------------------- -* 版权所有 (c) 2025 WenJY 保留所有权利。 -* CLR版本:4.0.30319.42000 -* 机器名称:Mr.Wen's MacBook Pro -* 命名空间:Sln.Imm.Daemon.Common -* 唯一标识:CE4BD2CC-E101-4CF0-BB9C-C3325F54C8FE -* -* 创建者:WenJY -* 电子邮箱: -* 创建时间:2025-09-05 11:10:34 -* 版本:V1.0.0 -* 描述: -* -*-------------------------------------------------------------------- -* 修改人: -* 时间: -* 修改说明: -* -* 版本:V1.0.0 -*--------------------------------------------------------------------*/ + * 版权所有 (c) 2025 WenJY 保留所有权利。 + * CLR版本:4.0.30319.42000 + * 机器名称:Mr.Wen's MacBook Pro + * 命名空间:Sln.Imm.Daemon.Common + * 唯一标识:CE4BD2CC-E101-4CF0-BB9C-C3325F54C8FE + * + * 创建者:WenJY + * 电子邮箱: + * 创建时间:2025-09-05 11:10:34 + * 版本:V1.0.0 + * 描述: + * + *-------------------------------------------------------------------- + * 修改人: + * 时间: + * 修改说明: + * + * 版本:V1.0.0 + *--------------------------------------------------------------------*/ #endregion << 版 本 注 释 >> @@ -28,253 +28,262 @@ using System.Text; namespace Sln.Imm.Daemon.Common; public class StringChange +{ + /// + /// 将字符串强制转换成int,转换失败则返回0 + /// + /// + /// + public int ParseToInt(string str) { - /// - /// 将字符串强制转换成int,转换失败则返回0 - /// - /// - /// - public int ParseToInt(string str) + int returnInt = 0; + if (str == null || str.Trim().Length < 1) { - int returnInt = 0; - if (str == null || str.Trim().Length < 1) - { - return returnInt; - } - if (int.TryParse(str, out returnInt)) - { - return returnInt; - } - else - { - return 0; - } + return returnInt; } - /// - /// char数组转Array - /// - /// - /// - /// - public string CharArrayToString(char[] cha, int len) + if (int.TryParse(str, out returnInt)) { - string str = ""; - for (int i = 0; i < len; i++) + return returnInt; + } + else + { + return 0; + } + } + + /// + /// char数组转Array + /// + /// + /// + /// + public string CharArrayToString(char[] cha, int len) + { + string str = ""; + for (int i = 0; i < len; i++) + { + str += string.Format("{0}", cha[i]); + } + + return str; + } + + + public byte[] HexStrTorbytes(string strHex) //e.g. " 01 01" ---> { 0x01, 0x01} + { + strHex = strHex.Replace(" ", ""); + if ((strHex.Length % 2) != 0) + strHex += " "; + byte[] returnBytes = new byte[strHex.Length / 2]; + for (int i = 0; i < returnBytes.Length; i++) + returnBytes[i] = Convert.ToByte(strHex.Substring(i * 2, 2), 16); + return returnBytes; + } + + public string StringToHexString(string s, Encoding encode) + { + byte[] b = encode.GetBytes(s); //按照指定编码将string编程字节数组 + string result = string.Empty; + for (int i = 0; i < b.Length; i++) //逐字节变为16进制字符,以%隔开 + { + result += "%" + Convert.ToString(b[i], 16); + } + + return result; + } + + public string HexStringToString(string hs, Encoding encode) + { + //以%分割字符串,并去掉空字符 + string[] chars = hs.Split(new char[] { '%' }, StringSplitOptions.RemoveEmptyEntries); + byte[] b = new byte[chars.Length]; + //逐个字符变为16进制字节数据 + for (int i = 0; i < chars.Length; i++) + { + b[i] = Convert.ToByte(chars[i], 16); + } + + //按照指定编码将字节数组变为字符串 + return encode.GetString(b); + } + + public byte[] Swap16Bytes(byte[] OldU16) + { + byte[] ReturnBytes = new byte[2]; + ReturnBytes[1] = OldU16[0]; + ReturnBytes[0] = OldU16[1]; + return ReturnBytes; + } + + /// + /// 获取时间戳 + /// + /// + public long GetTimeStamp() + { + TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds); + } + + public byte[] ConvertFloatToINt(byte[] floatBytes) + { + byte[] intBytes = new byte[floatBytes.Length / 2]; + for (int i = 0; i < intBytes.Length; i++) + { + intBytes[i] = floatBytes[i * 2]; + } + + return intBytes; + } + + //CRC异或校验 + public byte CalculateVerify(byte[] pMessage, int iLength) + { + UInt16 i; + byte iVerify = 0; + + iVerify = pMessage[0]; + for (i = 1; i < iLength; i++) + { + iVerify = (byte)(iVerify ^ pMessage[i]); + } + + return iVerify; + } + + public int HexStringToNegative(string strNumber) + { + int iNegate = 0; + int iNumber = Convert.ToInt32(strNumber, 16); + if (iNumber > 127) + { + int iComplement = iNumber - 1; + string strNegate = string.Empty; + char[] binchar = Convert.ToString(iComplement, 2).PadLeft(8, '0').ToArray(); + foreach (char ch in binchar) { - str += string.Format("{0}", cha[i]); - } - - return str; - } - - - - public byte[] HexStrTorbytes(string strHex)//e.g. " 01 01" ---> { 0x01, 0x01} - { - strHex = strHex.Replace(" ", ""); - if ((strHex.Length % 2) != 0) - strHex += " "; - byte[] returnBytes = new byte[strHex.Length / 2]; - for (int i = 0; i < returnBytes.Length; i++) - returnBytes[i] = Convert.ToByte(strHex.Substring(i * 2, 2), 16); - return returnBytes; - } - - public string StringToHexString(string s, Encoding encode) - { - byte[] b = encode.GetBytes(s); //按照指定编码将string编程字节数组 - string result = string.Empty; - for (int i = 0; i < b.Length; i++) //逐字节变为16进制字符,以%隔开 - { - result += "%" + Convert.ToString(b[i], 16); - } - return result; - } - - public string HexStringToString(string hs, Encoding encode) - { - //以%分割字符串,并去掉空字符 - string[] chars = hs.Split(new char[] { '%' }, StringSplitOptions.RemoveEmptyEntries); - byte[] b = new byte[chars.Length]; - //逐个字符变为16进制字节数据 - for (int i = 0; i < chars.Length; i++) - { - b[i] = Convert.ToByte(chars[i], 16); - } - //按照指定编码将字节数组变为字符串 - return encode.GetString(b); - } - - public byte[] Swap16Bytes(byte[] OldU16) - { - byte[] ReturnBytes = new byte[2]; - ReturnBytes[1] = OldU16[0]; - ReturnBytes[0] = OldU16[1]; - return ReturnBytes; - } - - /// - /// 获取时间戳 - /// - /// - public long GetTimeStamp() - { - TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); - return Convert.ToInt64(ts.TotalSeconds); - } - - public byte[] ConvertFloatToINt(byte[] floatBytes) - { - byte[] intBytes = new byte[floatBytes.Length / 2]; - for (int i = 0; i < intBytes.Length; i++) - { - intBytes[i] = floatBytes[i * 2]; - } - return intBytes; - } - - //CRC异或校验 - public byte CalculateVerify(byte[] pMessage, int iLength) - { - UInt16 i; - byte iVerify = 0; - - iVerify = pMessage[0]; - for (i = 1; i < iLength; i++) - { - iVerify = (byte)(iVerify ^ pMessage[i]); - } - return iVerify; - } - - public int HexStringToNegative(string strNumber) - { - - int iNegate = 0; - int iNumber = Convert.ToInt32(strNumber, 16); - if (iNumber > 127) - { - int iComplement = iNumber - 1; - string strNegate = string.Empty; - char[] binchar = Convert.ToString(iComplement, 2).PadLeft(8, '0').ToArray(); - foreach (char ch in binchar) + if (Convert.ToInt32(ch) == 48) { - if (Convert.ToInt32(ch) == 48) - { - strNegate += "1"; - } - else - { - strNegate += "0"; - } + strNegate += "1"; } - iNegate = -Convert.ToInt32(strNegate, 2); - } - return iNegate; - } - - - /// - /// Byte[] 转 uint16 - /// - /// - /// - /// - public void ConvertBytesToUInt16(byte[] buffer,out uint falg) - { - if (buffer == null || buffer.Length < 2) - { - throw new ArgumentException("Input array length must be at least 2."); - } - - var input = buffer.Reverse().ToArray(); - - falg = (uint) ((input[1] << 8) | input[0]); - } - - /// - /// Byte[] 移位转换 - /// - /// - /// - public void SwapBytes(ref byte[] input) - { - if (input == null || input.Length % 2 != 0) - { - throw new ArgumentException("Input array length must be a multiple of 2."); - } - - byte[] result = new byte[input.Length]; - - for (int j = 0; j < input.Length; j += 2) - { - ushort swapped = (ushort)((input[j + 1] << 8) | input[j]); - result[j] = (byte)(swapped >> 8); - result[j + 1] = (byte)swapped; - } - input = result; - } - - /// - /// Byte[] 转string - /// - /// - /// - public string ConverToString(byte[] data) - { - string str; - StringBuilder stb = new StringBuilder(); - for (int i = 0; i < data.Length; i++) - { - if ((int)data[i] > 15) + else { - stb.Append(Convert.ToString(data[i], 16).ToUpper()); //添加字符串 - } - else //如果是小于0F需要加个零 - { - stb.Append("0" + Convert.ToString(data[i], 16).ToUpper()); + strNegate += "0"; } } - str = stb.ToString(); - return str; - } - - /// - /// Byte[] 转 Hex - /// - /// - /// - /// - public string bytesToHexStr(byte[] bytes, int iLen) - { - StringBuilder sb = new StringBuilder(); - if (bytes != null) - { - for (int i = 0; i < iLen; i++) - { - sb.Append(bytes[i].ToString("X2")); - } - } - return sb.ToString(); - } - - /// - /// 校验计算 - /// - /// - /// - /// - public byte[] CalculateVerifyToArray(byte[] pMessage, int iLength) - { - UInt16 i; - int iVerify = 0; - iVerify = pMessage[0]; - for (i = 0; i < iLength - 1; i++) - { - iVerify = iVerify + pMessage[i + 1]; - } - return BitConverter.GetBytes(Convert.ToUInt16(iVerify)); + iNegate = -Convert.ToInt32(strNegate, 2); } - } \ No newline at end of file + + return iNegate; + } + + + /// + /// Byte[] 转 uint16 + /// + /// + /// + /// + public void ConvertBytesToUInt16(byte[] buffer, out uint falg) + { + if (buffer == null || buffer.Length < 2) + { + throw new ArgumentException("Input array length must be at least 2."); + } + + var input = buffer.Reverse().ToArray(); + + falg = (uint)((input[1] << 8) | input[0]); + } + + /// + /// Byte[] 移位转换 + /// + /// + /// + public void SwapBytes(ref byte[] input) + { + if (input == null || input.Length % 2 != 0) + { + throw new ArgumentException("Input array length must be a multiple of 2."); + } + + byte[] result = new byte[input.Length]; + + for (int j = 0; j < input.Length; j += 2) + { + ushort swapped = (ushort)((input[j + 1] << 8) | input[j]); + result[j] = (byte)(swapped >> 8); + result[j + 1] = (byte)swapped; + } + + input = result; + } + + /// + /// Byte[] 转string + /// + /// + /// + public string ConverToString(byte[] data) + { + string str; + StringBuilder stb = new StringBuilder(); + for (int i = 0; i < data.Length; i++) + { + if ((int)data[i] > 15) + { + stb.Append(Convert.ToString(data[i], 16).ToUpper()); //添加字符串 + } + else //如果是小于0F需要加个零 + { + stb.Append("0" + Convert.ToString(data[i], 16).ToUpper()); + } + } + + str = stb.ToString(); + return str; + } + + /// + /// Byte[] 转 Hex + /// + /// + /// + /// + public string bytesToHexStr(byte[] bytes, int iLen) + { + StringBuilder sb = new StringBuilder(); + if (bytes != null) + { + for (int i = 0; i < iLen; i++) + { + sb.Append(bytes[i].ToString("X2")); + } + } + + return sb.ToString(); + } + + /// + /// 校验计算 + /// + /// + /// + /// + public byte[] CalculateVerifyToArray(byte[] pMessage, int iLength) + { + UInt16 i; + int iVerify = 0; + + iVerify = pMessage[0]; + for (i = 0; i < iLength - 1; i++) + { + iVerify = iVerify + pMessage[i + 1]; + } + + return BitConverter.GetBytes(Convert.ToUInt16(iVerify)); + } +} \ No newline at end of file diff --git a/Sln.Imm.Daemon.Model/dao/BaseDeviceInfo.cs b/Sln.Imm.Daemon.Model/dao/BaseDeviceInfo.cs index a5edf64..82030e9 100644 --- a/Sln.Imm.Daemon.Model/dao/BaseDeviceInfo.cs +++ b/Sln.Imm.Daemon.Model/dao/BaseDeviceInfo.cs @@ -30,7 +30,7 @@ namespace Sln.Imm.Daemon.Model.dao; /// /// 设备信息 /// -[SugarTable("ems_base_monitor_info"), TenantAttribute("mes")] +[SugarTable("BASE_DEVICELEDGER"), TenantAttribute("mes")] public class BaseDeviceInfo { /// @@ -38,166 +38,53 @@ public class BaseDeviceInfo /// Default: /// Nullable:False /// - [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "obj_id")] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "OBJ_ID")] public int objid { get; set; } /// - /// Desc:父级编号 + /// Desc:设备编号 /// Default: - /// Nullable:True + /// Nullable:False /// - [SugarColumn(ColumnName = "parent_id")] - public int? parentId { get; set; } + [SugarColumn(ColumnName = "DEVICE_CODE")] + public string deviceCode { get; set; } /// - /// Desc:计量设备编号 + /// Desc:设备名称 /// Default: /// Nullable:False /// - [SugarColumn(IsPrimaryKey = true, ColumnName = "monitor_code")] - public string monitorId { get; set; } + [SugarColumn(ColumnName = "DEVICE_NAME")] + public string deviceName { get; set; } /// - /// Desc:计量设备名称 + /// Desc:设备型号 /// Default: /// Nullable:True /// - [SugarColumn(ColumnName = "monitor_name")] - public string monitorName { get; set; } + [SugarColumn(ColumnName = "DEVICE_MODEL")] + public string deviceModel { get; set; } /// - /// Desc:计量设备位置 + /// Desc:网络地址 /// Default: /// Nullable:True /// - [SugarColumn(ColumnName = "monitor_addr")] - public string monitorAddr { get; set; } + [SugarColumn(ColumnName = "DEVICE_ADDRESS")] + public string networkAddress { get; set; } /// - /// Desc:计量设备类型 + /// Desc:设备状态 /// Default: /// Nullable:True /// - [SugarColumn(ColumnName = "monitor_type")] - public int? monitorType { get; set; } + [SugarColumn(ColumnName = "DEVICE_STATUS")] + public int? deviceStatus { get; set; } /// - /// Desc:计量设备状态 - /// Default:0 - /// Nullable:True + /// 设备参数集合 /// - [SugarColumn(ColumnName = "monitor_status")] - public int? monitorStatus { get; set; } - - /// - /// Desc:采集设备编号 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "collect_device_id")] - public string collectDeviceId { get; set; } - - /// - /// Desc:祖级列表 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "ancestors")] - public string ancestors { get; set; } - - /// - /// Desc:等级 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "grade")] - public int? grade { get; set; } - - /// - /// Desc:传感器仪表 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "meter_type_id")] - public string meterTypeId { get; set; } - - /// - /// Desc:修正值 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "correct_value")] - public decimal? correctValue { get; set; } - - /// - /// Desc:PT值 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "pt")] - public int? pt { get; set; } - - /// - /// Desc:CT值 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "ct")] - public int? ct { get; set; } - - /// - /// Desc:是否虚拟 - /// Default:false - /// Nullable:True - /// - [SugarColumn(ColumnName = "is_ammeter")] - public string isAmmeter { get; set; } - - /// - /// Desc:通断复位 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "is_key_monitor")] - public int? isKeyMonitor { get; set; } - - /// - /// Desc:是否断路 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "is_circuit")] - public int? isCircuit { get; set; } - - /// - /// Desc:创建人 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "create_by")] - public string createBy { get; set; } - - /// - /// Desc:创建时间 - /// Default:CURRENT_TIMESTAMP - /// Nullable:True - /// - [SugarColumn(ColumnName = "create_time")] - public DateTime? createTime { get; set; } - - /// - /// Desc:更新人 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "update_by")] - public string updateBy { get; set; } - - /// - /// Desc:更新时间 - /// Default: - /// Nullable:True - /// - [SugarColumn(ColumnName = "update_time")] - public DateTime? updateTime { get; set; } + ///[SugarColumn(IsIgnore = true)] + [Navigate(NavigateType.OneToMany, nameof(BaseDeviceParam.deviceCode), nameof(deviceCode))] + public List deviceParams { get; set; } } \ No newline at end of file diff --git a/Sln.Imm.Daemon.Model/dao/BaseDeviceParam.cs b/Sln.Imm.Daemon.Model/dao/BaseDeviceParam.cs index a0fa4b5..0d0da4a 100644 --- a/Sln.Imm.Daemon.Model/dao/BaseDeviceParam.cs +++ b/Sln.Imm.Daemon.Model/dao/BaseDeviceParam.cs @@ -1,25 +1,25 @@ #region << 版 本 注 释 >> /*-------------------------------------------------------------------- -* 版权所有 (c) 2025 WenJY 保留所有权利。 -* CLR版本:4.0.30319.42000 -* 机器名称:Mr.Wen's MacBook Pro -* 命名空间:Sln.Imm.Daemon.Model.dao -* 唯一标识:471106BA-23AA-4923-99A0-EBF103DAD909 -* -* 创建者:WenJY -* 电子邮箱: -* 创建时间:2025-09-05 11:15:14 -* 版本:V1.0.0 -* 描述: -* -*-------------------------------------------------------------------- -* 修改人: -* 时间: -* 修改说明: -* -* 版本:V1.0.0 -*--------------------------------------------------------------------*/ + * 版权所有 (c) 2025 WenJY 保留所有权利。 + * CLR版本:4.0.30319.42000 + * 机器名称:Mr.Wen's MacBook Pro + * 命名空间:Sln.Imm.Daemon.Model.dao + * 唯一标识:471106BA-23AA-4923-99A0-EBF103DAD909 + * + * 创建者:WenJY + * 电子邮箱: + * 创建时间:2025-09-05 11:15:14 + * 版本:V1.0.0 + * 描述: + * + *-------------------------------------------------------------------- + * 修改人: + * 时间: + * 修改说明: + * + * 版本:V1.0.0 + *--------------------------------------------------------------------*/ #endregion << 版 本 注 释 >> @@ -30,8 +30,70 @@ namespace Sln.Imm.Daemon.Model.dao; /// /// 设备采集参数 /// -[SugarTable("ems_base_monitor_info"), TenantAttribute("mes")] +[SugarTable("BASE_DEVICEPARAM"), TenantAttribute("mes")] public class BaseDeviceParam { - + /// + /// Desc:自增标识 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "OBJ_ID")] + public int objid { get; set; } + + /// + /// Desc:设备编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "DEVICE_CODE")] + public string deviceCode { get; set; } + + /// + /// Desc:参数编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "PARAM_CODE")] + public string paramCode { get; set; } + + /// + /// Desc:参数名称 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "PARAM_NAME")] + public string paramName { get; set; } + + /// + /// Desc:网络地址 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "PARAM_NETWORK")] + public string netWork { get; set; } + + /// + /// Desc: 参数地址 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "PARAM_ADDRESS")] + public string paramAddr { get; set; } + + /// + /// Desc: 参数类型 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "PARAM_TYPE")] + public string paramType { get; set; } + + /// + /// Desc: 是否启用 + /// Default: + /// Nullable:False + /// + [SugarColumn(ColumnName = "IS_FLAG")] + public int isFlag { get; set; } } \ No newline at end of file diff --git a/Sln.Imm.Daemon.Repository/service/IBaseDeviceInfoService.cs b/Sln.Imm.Daemon.Repository/service/IBaseDeviceInfoService.cs index d6ade53..9463f1c 100644 --- a/Sln.Imm.Daemon.Repository/service/IBaseDeviceInfoService.cs +++ b/Sln.Imm.Daemon.Repository/service/IBaseDeviceInfoService.cs @@ -30,4 +30,9 @@ namespace Sln.Imm.Daemon.Repository.service; public interface IBaseDeviceInfoService : IBaseService { + /// + /// 通过导航查询方式获取设备信息及下属参数 + /// + /// + List GetDeviceInfosByNavigate(); } \ No newline at end of file diff --git a/Sln.Imm.Daemon.Repository/service/Impl/BaseDeviceInfoServiceImpl.cs b/Sln.Imm.Daemon.Repository/service/Impl/BaseDeviceInfoServiceImpl.cs index 7854e08..7a2f8a7 100644 --- a/Sln.Imm.Daemon.Repository/service/Impl/BaseDeviceInfoServiceImpl.cs +++ b/Sln.Imm.Daemon.Repository/service/Impl/BaseDeviceInfoServiceImpl.cs @@ -25,6 +25,7 @@ using Sln.Imm.Daemon.Model.dao; using Sln.Imm.Daemon.Repository.service.@base; +using SqlSugar; namespace Sln.Imm.Daemon.Repository.service.Impl; @@ -33,4 +34,22 @@ public class BaseDeviceInfoServiceImpl : BaseServiceImpl, IBaseD public BaseDeviceInfoServiceImpl(Repository rep) : base(rep) { } + + /// + /// 通过导航查询方式获取设备信息及下属参数 + /// + /// + /// + public List GetDeviceInfosByNavigate() + { + try + { + return _rep.Context.Queryable().Includes(x => x.deviceParams) + .ToList(); + } + catch (Exception ex) + { + throw new InvalidOperationException($"通过导航查询方式获取设备信息及下属参数执行异常:{ex.Message}"); + } + } } \ No newline at end of file diff --git a/Sln.Imm.Daemon/Program.cs b/Sln.Imm.Daemon/Program.cs index 7233b58..29c8afb 100644 --- a/Sln.Imm.Daemon/Program.cs +++ b/Sln.Imm.Daemon/Program.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using NeoSmart.Caching.Sqlite; +using Sln.Imm.Daemon.Cache; using Sln.Imm.Daemon.Config; using Sln.Imm.Daemon.Repository; using Sln.Imm.Daemon.Serilog; @@ -24,6 +25,12 @@ namespace Sln.Imm.Daemon var appConfig = ServiceProvider.GetService(); var log = ServiceProvider.GetService(); log.Info($"系统启动成功,日志存放位置:{appConfig.logPath}"); + + var baseDeviceInfoCacheService = ServiceProvider.GetService(); + var valueAsync = baseDeviceInfoCacheService.GetValueAsync("FusionCacheExerciseKey"); + + Thread.Sleep(2000); + var valueAsync2 = baseDeviceInfoCacheService.GetValueAsync("FusionCacheExerciseKey"); } private static void ConfigureServices(IServiceCollection services) @@ -40,11 +47,11 @@ namespace Sln.Imm.Daemon Assembly[] assemblies = { - Assembly.LoadFrom("Sln.Iot.Common.dll"), - Assembly.LoadFrom("Sln.Iot.Repository.dll"), + Assembly.LoadFrom("Sln.Imm.Daemon.Common.dll"), + Assembly.LoadFrom("Sln.Imm.Daemon.Repository.dll"), + Assembly.LoadFrom("Sln.Imm.Daemon.Cache.dll"), // Assembly.LoadFrom("Sln.Iot.Socket.dll"), // Assembly.LoadFrom("Sln.Iot.Business.dll"), - // Assembly.LoadFrom("Sln.Iot.Cache.dll"), }; services.Scan(scan => scan.FromAssemblies(assemblies) diff --git a/Sln.Imm.Daemon/Sln.Imm.Daemon.csproj b/Sln.Imm.Daemon/Sln.Imm.Daemon.csproj index e934311..32d6370 100644 --- a/Sln.Imm.Daemon/Sln.Imm.Daemon.csproj +++ b/Sln.Imm.Daemon/Sln.Imm.Daemon.csproj @@ -14,6 +14,7 @@ + diff --git a/Sln.Imm.Daemon/appsettings.json b/Sln.Imm.Daemon/appsettings.json index f04ed9c..f85720c 100644 --- a/Sln.Imm.Daemon/appsettings.json +++ b/Sln.Imm.Daemon/appsettings.json @@ -1,14 +1,14 @@ { - "AppConfig": { - "logPath": "/Users/wenxiansheng/Public/WorkSpace/Mesnac/项目资料/澳柯玛注塑车间MES项目/日志信息", - "SqlConfig": [ - { - "configId": "mes", //imm:注塑设备简称 - "dbType": 0, //tidb按照 mysql 去连接 - "isFlag": false, - "connStr": "server=127.0.0.1;Port=4000;Database=tao_iot;Uid=root;" //Pwd=haiwei@123; - //"connStr": "server=1.13.177.47;Port=3306;Database=tao_iot;Uid=root;Pwd=Haiwei123456;" - } - ] - } + "AppConfig": { + "logPath": "/Users/wenxiansheng/Public/WorkSpace/Mesnac/项目资料/澳柯玛注塑车间MES项目/日志信息", + "SqlConfig": [ + { + "configId": "mes", + "dbType": 3, + "isFlag": true, + //"connStr": "server=127.0.0.1;Port=4000;Database=tao_iot;Uid=root;" + "connStr": "Data Source=1.13.177.47:1521/helowin;User ID=c##aucma_mes;Password=aucma;" + } + ] + } } \ No newline at end of file