BulletinBoardController.cs
9.98 KB
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
using System;
using Hh.Mes.Common.log;
using Hh.Mes.Pojo.System;
using Hh.Mes.Service;
using Hh.Mes.Service.WebService.Equipment;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Hh.Mes.Api.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
[ServiceFilter(typeof(ValidateUserAttribute))]
public class BulletinBoardController : BaseController
{
private readonly BulletinBoardService service;
private readonly BaseInfoCacheService baseInfo;
private readonly EquipmentVisualService equipmentVisual;
/// <summary>
/// 用户信息
/// </summary>
private UserAuthSession UserInfo { get; set; }
public BulletinBoardController(BulletinBoardService service, BaseInfoCacheService baseInfo, EquipmentVisualService equipmentVisual, IHttpContextAccessor accessor)
{
this.service = service;
this.baseInfo = baseInfo;
this.equipmentVisual = equipmentVisual;
this.context = accessor.HttpContext;
}
#region 故障相关接口
#region 故障报告
[HttpGet]
public string GetFaultReport(string yyyyMonth, string projectCode, string equipmentTypeCode)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetFaultReport(yyyyMonth, projectCode, equipmentTypeCode);
return Serialize(result);
}
#endregion
#region 故障分析
/// <summary>
/// 故障分析查询
/// </summary>
/// <param name="begin">开始时间</param>
/// <param name="end">结束时间</param>
/// <param name="projectCode">项目编码</param>
/// <param name="equipmentCode">设备编码</param>
/// <returns></returns>
[HttpGet]
public string FaultStatistics(string begin, string end, string projectCode, string equipmentCode)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.FaultStatistics(begin, end, projectCode, equipmentCode);
return Serialize(result);
}
#endregion
#region 妥善率
/// <summary>
/// 妥善率趋势图
/// </summary>
[HttpGet]
public string GetProperRate(string startTime, string endTime, string yearOrdaySelectVal, string timeFlag, string projectCode, string equipmentCode)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetProperRate(startTime, endTime, yearOrdaySelectVal, timeFlag, projectCode, equipmentCode);
return Serialize(result);
}
#endregion
#region 故障月份对比
[HttpGet]
public string FailureMonthCompare(int year, int month, string projectCode, string equipmentTypeCode)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetFailureMonthCompare(year, month, projectCode, equipmentTypeCode);
return Serialize(result);
}
#endregion
#region 获取基础数据
[HttpGet]
public string GetBaseInfoByKeyExtend(string key, string falg)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var isRemore = falg == "1";
var result = baseInfo.GetOneBaseInfo(key, isRemore);
if (string.IsNullOrEmpty(result))
{
return "{\"code\":500,\"status\":false,\"message\":\"ok\",\"data\":null}";
}
return "{\"code\":200,\"status\":true,\"message\":\"ok\",\"data\":" + result + "}";
});
}
/// <summary>
/// 获取所有项目(如果是AGV报表则只查询有AGV设备的项目)
/// </summary>
/// <param name="agvTag"></param>
/// <returns></returns>
[HttpGet]
public string GetProjects(bool agvTag = false)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetProjects(agvTag);
return Serialize(result);
}
/// <summary>
/// 获取项目下的所有设备
/// </summary>
/// <param name="projectCode"></param>
/// <returns></returns>
[HttpGet]
public string GetEquipmentsByProject(string projectCode, bool agvTag = false)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetEquipmentsByProject(projectCode, agvTag);
return Serialize(result);
}
#endregion
#region 月每周故障次数、时间
[HttpGet]
public string FailureMonthWeekCountAndTime(string projectCode, DateTime currentDate)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetFailureMonthWeekCountAndTime(projectCode, currentDate);
return Serialize(result);
}
#endregion
#region 项目某设备某天每小时故障次数
[HttpGet]
public string FailureEveryHourCount(string projectCode, string equipmentCode, DateTime currentDate)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetFailureEveryHourCount(projectCode, equipmentCode, currentDate);
return Serialize(result);
}
#endregion
#region 故障重复次数
/// <summary>
/// 故障次数
/// </summary>
/// <param name="projectCode"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
[HttpGet]
public string FailureAlarmCount(string projectCode, DateTime startTime, DateTime endTime)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetFailureAlarmCount(projectCode, startTime, endTime);
return Serialize(result);
}
#endregion
#endregion
#region AGV报表接口
#region 获取AGV异常故障内容下拉框数据源
public string GetAGVAlarmList(string projectCode, string equipmentCode)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetAGVAlarmList(projectCode, equipmentCode);
return Serialize(result);
}
#endregion
#region 获取AGV异常分析(点位维度)
[HttpGet]
public string GetAGVCodePointAlarmRecord(string startTime, string endTime, string projectCode, string equipmentCode, string alarmMsg)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetAGVCodePointAlarmRecord(startTime, endTime, projectCode, equipmentCode, alarmMsg);
return Serialize(result);
}
#endregion
#region 获取AGV异常分析(时间维度)
[HttpGet]
public string GetAGVAbnormalRecord(string startTime, string endTime, string projectCode, string equipmentCode, string alarmMsg)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetAGVAbnormalRecord(startTime, endTime, projectCode, equipmentCode, alarmMsg);
return Serialize(result);
}
#endregion
#region 获取AGV故障任务妥善率(故障次数/任务数)
[HttpGet]
public string GetAGVProperRate(string startTime, string endTime, string yearOrdaySelectVal, string timeFlag, string projectCode, string equipmentCode)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetAGVProperRate(startTime, endTime, yearOrdaySelectVal, timeFlag, projectCode, equipmentCode);
return Serialize(result);
}
#endregion
#endregion
#region 设备保养模块接口
/// <summary>
/// 设备保养报告
/// </summary>
/// <param name="projectKeys"></param>
/// <param name="equipmentCode"></param>
/// <param name="month"></param>
/// <returns></returns>
[HttpGet]
public string GetEqMaintainReport(string projectCode, string equipmentCode, string yearMonth, bool thisMonth = false)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetEqMaintainReport(projectCode, equipmentCode, yearMonth, thisMonth);
return Serialize(result);
}
/// <summary>
/// 设备保养次数趋势图 接口
/// </summary>
/// <param name="projectKeys"></param>
/// <param name="yearMonth"></param>
/// <returns></returns>
[HttpGet]
public string GetEqMaintainCount(string projectCode, string yearMonth)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetEqMaintainCount(projectCode, yearMonth);
return Serialize(result);
}
#endregion
#region 设备健康分析接口
public string GetEquipmentMaintainStatus(string projectCode, DateTime date, string equipmentCode)
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetEquipmentMaintainStatus(projectCode, date, equipmentCode, equipmentVisual);
return Serialize(result);
}
#endregion
}
}