schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using DataEntity.Device;
using DataEntity.Page;
using DataRWDAL.Base;
using HxEnum;
using SqlSugar;
using System;
using System.Collections.Generic;
using XCommon.SqlSugar;
 
namespace DataRWDAL.Device
{
    /// <summary>
    /// 方法参数数据操作类
    /// </summary>
    public class DeviceConfigMethodParametersDB : BaseDB
    {
        /// <summary>
        /// 获取方法参数分页数据
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static Tuple<List<DeviceConfigMethodParametersModel>, int> GetPageData(Pagination pagination, DeviceConfigMethodParametersModel condition)
        {
            using (var db = GetInstance())
            {
                var whereExpression = LinqExtensions.True<DeviceConfigMethodParametersModel>();
                whereExpression = whereExpression.And(it => it.DeviceconfigMethodId.Equals(condition.DeviceconfigMethodId));
 
                if (!string.IsNullOrEmpty(condition.ParameterName))
                {
                    whereExpression = whereExpression.And(it => it.ParameterName.Contains(condition.ParameterName));
                }
                // u => u.Sort
                return GetPage<DeviceConfigMethodParametersModel>(pagination, whereExpression, u => u.Sort, OrderByType.Asc);
            }
        }
 
        /// <summary>
        /// 根据方法参数Id,获取参数信息
        /// </summary>
        /// <param name="methodParameterId"></param>
        /// <returns></returns>
        public static DeviceConfigMethodParametersModel GetInfodById(string methodParameterId)
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodParametersModel>().Single(it => it.Id.Equals(methodParameterId));
            }
        }
 
        /// <summary>
        /// 获取设备方法参数信息
        /// </summary>
        /// <param name="deviceconfigId"></param>
        /// <param name="deviceconfigMethodId"></param>
        /// <param name="type"></param>
        /// <param name="parameterName"></param>
        /// <returns></returns>
        public static List<DeviceConfigMethodParametersModel> GetInfo(string deviceconfigId, string deviceconfigMethodId, int type, string parameterName)
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodParametersModel>().Where(it => it.DeviceconfigId.Equals(deviceconfigId) &&
                    it.DeviceconfigMethodId.Equals(deviceconfigMethodId) && it.Type == type && it.ParameterName.Equals(parameterName)).
                    OrderBy(t => t.CreateTime, OrderByType.Asc).ToList();
            }
        }
 
        /// <summary>
        /// 获取设备方法参数列表
        /// </summary>
        /// <param name="deviceconfigMethodId"></param>
        /// <returns></returns>
        public static List<DeviceConfigMethodParametersModel> GetInfoByDeviceconfigMethodId(string deviceconfigMethodId)
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodParametersModel>().Where(it => it.DeviceconfigMethodId.Equals(deviceconfigMethodId)).
                    OrderBy(t => t.CreateTime, OrderByType.Asc).ToList();
            }
        }
 
        public static List<DeviceConfigMethodParametersModel> GetInfoByDeviceconfigMethodId(string deviceconfigMethodId, ParameterTypeEnum parameterType)
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodParametersModel>().Where(it => it.DeviceconfigMethodId.Equals(deviceconfigMethodId) &&
                    it.Type == EnumManagement.GetEnumValue(parameterType)).OrderBy(t => t.CreateTime, OrderByType.Asc).ToList();
            }
        }
 
        /// <summary>
        /// 登录设备信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Add(DeviceConfigMethodParametersModel model)
        {
            using (var db = GetInstance())
            {
                return db.Insertable<DeviceConfigMethodParametersModel>(model).ExecuteCommand();
            }
        }
 
        /// <summary>
        /// 更新设备信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Update(DeviceConfigMethodParametersModel model)
        {
            using (var db = GetInstance())
            {
                return db.Updateable<DeviceConfigMethodParametersModel>(model).ExecuteCommand();
            }
        }
 
        /// <summary>
        /// 删除设备方法参数
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int DelById(DeviceConfigMethodParametersModel model)
        {
            using (var db = GetInstance())
            {
                return db.Deleteable<DeviceConfigMethodParametersModel>(model).ExecuteCommand();
            }
        }
 
        /// <summary>
        /// 获取设备方法参数列表
        /// </summary>
        /// <returns></returns>
        public static List<DeviceConfigMethodParametersModel> GetDeviceConfigMethodParametersList()
        {
            using (var db = GetInstance())
            {
                return db.Queryable<DeviceConfigMethodParametersModel>().OrderBy(it => it.Id, OrderByType.Asc).ToList();
            }
        }
    }
}