BulletinBoardController.cs
8.37 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
using System;using System.Collections.Generic;using Hh.Mes.Api.Controllers;using Hh.Mes.Common.Json;using Hh.Mes.Common.log;
using Hh.Mes.Common.Redis;
using Hh.Mes.Pojo.System;
using Hh.Mes.Service;using Hh.Mes.Service.ApiService;
using Microsoft.AspNetCore.Hosting;using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Http.Headers;
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] //[ValidateUser] public class BulletinBoardController : BaseController { private readonly BulletinBoardService service;
private readonly BaseInfoCacheService baseInfo;
/// <summary>
/// 用户信息
/// </summary>
private UserAuthSession UserInfo { get; set; } public BulletinBoardController(BulletinBoardService service, BaseInfoCacheService baseInfo, IHttpContextAccessor accessor) { this.service = service; this.baseInfo = baseInfo; this.context = accessor.HttpContext; }
#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
#region 获取AGV异常故障内容下拉框数据源
public string GetAGVAlarmList()
{
this.service.sysUserApiAccount = HttpContext.Items["Account"] as string;
var result = service.GetAGVAlarmList();
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
}}