111
yanjinhui
2025-03-28 2d4e07b5d61490d3c3cfeb398d3d6e4b6f8be9bb
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_ITelescopicService;
using WIDESEAWCS_Model.Models;
<<<<<<< Updated upstream
=======
using WIDESEAWCS_DTO;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using WIDESEAWCS_DTO.Telescopic;
>>>>>>> Stashed changes
 
namespace WIDESEAWCS_TelescopicService
{
    public class MaintenanceService : ServiceBase<Dt_Maintenance, IRepository<Dt_Maintenance>>, IMaintenanceService
    {
        public IRepository<Dt_Maintenance> Repository => BaseDal;
        private readonly IRepository<Sys_User> _user;
 
        public MaintenanceService(IRepository<Dt_Maintenance> BaseDal, IRepository<Sys_User> user) : base(BaseDal)
        {
            _user = user;
        }
<<<<<<< Updated upstream
 
        public WebResponseContent ShowMaintence()
=======
        public WebResponseContent ShowMaintence(PaginationDTO pagination)
>>>>>>> Stashed changes
        {
            try
            {
                var sys = _user.QueryData();
                var main = BaseDal.QueryData();
 
<<<<<<< Updated upstream
                var result = sys.Join(main,
                    u => u.UserName,
                    m => m.UserAccount,
                    (u, m) => new
                    {
                        u.UserTrueName,
                        u.UserName,
                        u.CardNumber,
                        u.RoleName,
                        u.HeadImageUrl,
                        m.IsPossible,
                    });
                return new WebResponseContent { Status = true, Data = result };
=======
                var query = sys.InnerJoin<Dt_Maintenance>((a, b) => a.UserName == b.UserAccount);
                if (!string.IsNullOrEmpty(pagination.searchKeyword))
                {
                    query = query.Where((a, b) =>
                       a.UserTrueName.Contains(pagination.searchKeyword) ||
                         a.UserName.Contains(pagination.searchKeyword) ||
                        a.CardNumber.ToString().Contains(pagination.searchKeyword)||
                         a.Userteam.Contains(pagination.searchKeyword)
                    );
                }
                    var result= query .Select((a, b) => new
                            {
                               b.ID,
                               a.UserTrueName,
                               a.UserName,
                               a.CardNumber,
                               a.Userteam,
                               a.HeadImageUrl,
                               b.IsPossible
                           }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount);
                return new WebResponseContent
                {
                    Status = true,
                    Data = new
                    {
                        TotalCount = totalCount,//总数
                        PageIndex = pagination.pageIndex,//页数
                        PageSize = pagination.pageSize,//一页多少个数据
                        Items = result
                    }
                };
>>>>>>> Stashed changes
            }
            catch (Exception ex)
            {
 
                return new WebResponseContent { Status = false, Data = ex };
            }
        }
 
<<<<<<< Updated upstream
        public WebResponseContent PersonnelMonitoring(bool ispossible)
=======
 
 
 
        /// <summary>
        /// 模糊查询
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="searchKeyword"></param>
        /// <returns></returns>
        public WebResponseContent PersonnelMonitoring(PaginationDTO pagination)
>>>>>>> Stashed changes
        {
            try
            {
                var sys = _user.QueryData();
                var main = BaseDal.QueryData();
 
<<<<<<< Updated upstream
                var result = sys.Join(main,
                    u => u.UserName,
                    m => m.UserAccount,
                    (u, m) => new
                    {
                        u.UserTrueName,
                        u.RoleName,
                        u.HeadImageUrl,
                        m.MaintenanceStatus,
                        m.MaintenanceDate,
                        m.IsPossible,
                    }).Where(x=>x.IsPossible== ispossible);
                return new WebResponseContent { Status = true, Data = result };
=======
                var query = sys.InnerJoin<Dt_Maintenance>((a, b) => a.UserName == b.UserAccount)
                               .Where((a, b) => b.IsPossible == "true"); // 先筛选 IsPossible 为 true 的数据
 
                // 如果提供了搜索关键字,则进行模糊查询
                if (!string.IsNullOrEmpty(pagination.searchKeyword))
                {
                    query = query.Where((a, b) =>
                        a.UserTrueName.Contains(pagination.searchKeyword) ||   // 按真实姓名模糊搜索
                        a.Userteam.Contains(pagination.searchKeyword));        // 按用户班组模糊搜索
                }
 
                // 如果提供了 status 参数,则按状态筛选
                if (pagination.status.HasValue)//等价if(status!=null)
                {
                    query = query.Where((a, b) => b.MaintenanceStatus == pagination.status.Value);
                }
 
                var result = query
                    .Select((a, b) => new
                    {
                        a.UserTrueName,
                        a.Userteam,
                        a.HeadImageUrl,
                        b.MaintenanceStatus,
                        b.MaintenanceDate,
                        b.IsPossible,
                    })
                    .ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); // 分页
 
                return new WebResponseContent
                {
                    Status = true,
                    Data = new
                    {
                        TotalCount = totalCount, // 总数
                        PageIndex = pagination.pageIndex,   // 当前页码
                        PageSize = pagination.pageSize,     // 每页数据量
                        Items = result
                    }
                };
>>>>>>> Stashed changes
            }
            catch (Exception ex)
            {
 
                return new WebResponseContent { Status = false, Data = ex };
            }
        }
 
        public WebResponseContent RunOperation(int id)
        {
            try
            {
                var mon = BaseDal.QueryFirst(x => x.ID == id);
                mon.IsPossible = true;
                BaseDal.UpdateData(mon);
                return new WebResponseContent { Status = true, Data = mon };
            }
            catch (Exception ex)
            {
 
                return new WebResponseContent { Status = false, Message = "失败:" + ex };
            }
        }
 
        public WebResponseContent ChangeTasState(int id)
        {
            try
            {
                var change = BaseDal.QueryFirst(x => x.ID == id);
                //将数据库中的int 值转为 枚举型
                if (!Enum.IsDefined(typeof(Maint), change.MaintenanceStatus))
                {
                    return new WebResponseContent { Status = false, Message = "当前状态不合法,无法更新" };
                }
 
                Maint Status = (Maint)change.MaintenanceStatus; //int ->枚举
 
                switch (Status)
                {
                    case Maint.待开始:
                        change.MaintenanceStatus = (int)Maint.检修中;
                        change.MaintenancStartTime = DateTime.Now;
                        break;
                    case Maint.检修中:
                        change.MaintenanceStatus = (int)Maint.已完成;
                        break;
                    case Maint.已完成:
                        change.MaintenancEendTime = DateTime.Now;
                        return new WebResponseContent { Status = false, Message = "当前任务已完成" };
                    default:
                        return new WebResponseContent { Status = false, Message = "更新失败" };
                }
                return new WebResponseContent { Status = true, Data = change };
            }
            catch (Exception ex)
            {
 
                return new WebResponseContent { Status = false, Message = "错误:" + ex };
            }
 
 
        }
 
        /// <summary>
<<<<<<< Updated upstream
=======
        /// 检修操作记录
        /// </summary>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageSize">一页多少个数据</param>
        /// <returns></returns>
        public WebResponseContent MaintenanceOperationRecord(PaginationDTO pagination)
        {
            try
            {
                int totalCount = 0;
                var sys = _user.Db.Queryable<Sys_User>();
                var main = Db.Queryable<Dt_Maintenance>();
 
                var query = sys.InnerJoin<Dt_Maintenance>((a, b) => a.UserName == b.UserAccount);
 
                if (!string.IsNullOrEmpty(pagination.searchKeyword))
                {
                    query = query.Where((a, b) =>
                        a.UserTrueName.Contains(pagination.searchKeyword)||
                        a.Userteam.Contains(pagination.searchKeyword)||
                        a.HeadImageUrl.Contains(pagination.searchKeyword)
                    );
                }
 
                if (pagination.startDate.HasValue && pagination.endDate.HasValue)
                {
                    query = query.Where((a, b) => b.MaintenancStartTime >= pagination.startDate.Value && b.MaintenancStartTime <= pagination.endDate.Value);
                }
 
                var result = query.Select((a, b) => new
                {
                    a.UserTrueName,
                    a.Userteam,
                    a.HeadImageUrl,
                    b.MaintenancStartTime,
                    b.MaintenancEendTime,
                }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount);
 
                return new WebResponseContent
                {
                    Status = true,
                    Data = new
                    {
                        TotalCount = totalCount,//总数
                        PageIndex = pagination.pageIndex,//页数
                        PageSize = pagination.pageSize,//一页多少个数据
                        Items = result
                    }
                };
            }
            catch (Exception ex)
            {
 
                return new WebResponseContent { Status = false, Message = "错误信息:" + ex.Message };
            }
        }
 
      
 
        /// <summary>
>>>>>>> Stashed changes
        /// 状态枚举
        /// </summary>
        private enum Maint
        {
            //待检修=0,
            待开始=0,
            检修中=1,
            已完成=2
 
        }
 
    }
}