|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+using RMYY_CallCenter_Api.Models.Enum;
|
|
|
2
|
+using RMYY_CallCenter_Api.Models.Input;
|
|
|
3
|
+using RMYY_CallCenter_Api.Utility;
|
|
|
4
|
+using System;
|
|
|
5
|
+using System.Collections.Generic;
|
|
|
6
|
+using System.IO;
|
|
|
7
|
+using System.Linq;
|
|
|
8
|
+using System.Web;
|
|
|
9
|
+using System.Web.Mvc;
|
|
|
10
|
+
|
|
|
11
|
+namespace RMYY_CallCenter_Api.Controllers
|
|
|
12
|
+{
|
|
|
13
|
+ public class FaultRepairController : BaseController
|
|
|
14
|
+ {
|
|
|
15
|
+ private BLL .T_FaultRepair_Base baseBll = new BLL.T_FaultRepair_Base();
|
|
|
16
|
+ private BLL.T_FaultRepair_Evaluate evaBll = new BLL.T_FaultRepair_Evaluate();
|
|
|
17
|
+ private BLL.T_FaultRepair_OperationLog logBll = new BLL.T_FaultRepair_OperationLog();
|
|
|
18
|
+ private BLL.T_FaultRepair_Process dealBll = new BLL.T_FaultRepair_Process();
|
|
|
19
|
+ Bll.T_Sys_GongDan gdbll = new Bll.T_Sys_GongDan();
|
|
|
20
|
+
|
|
|
21
|
+ private Bll.T_Sys_DictionaryValue dictionaryValueBLL = new Bll.T_Sys_DictionaryValue();
|
|
|
22
|
+
|
|
|
23
|
+
|
|
|
24
|
+ /// <summary>
|
|
|
25
|
+ /// 上传附件
|
|
|
26
|
+ /// </summary>
|
|
|
27
|
+ /// <returns></returns>
|
|
|
28
|
+ //[Authority]
|
|
|
29
|
+ public ActionResult UploadFile()
|
|
|
30
|
+ {
|
|
|
31
|
+ #region 多个上传
|
|
|
32
|
+ HttpFileCollectionBase files = Request.Files;
|
|
|
33
|
+ if (files.Count > 0)
|
|
|
34
|
+ {
|
|
|
35
|
+ List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
|
|
|
36
|
+ string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
|
|
|
37
|
+ for (int i = 0; i < files.Count; i++)
|
|
|
38
|
+ {
|
|
|
39
|
+ HttpPostedFileBase file = files[i];
|
|
|
40
|
+ string name = FileHelper.Upload(file, path);
|
|
|
41
|
+
|
|
|
42
|
+ Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
|
|
|
43
|
+ model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
|
|
|
44
|
+ model_T_Sys_Accessories.F_FileName = name;//附件名称
|
|
|
45
|
+ model_T_Sys_Accessories.F_FileType = Path.GetExtension(file.FileName);//附件类型
|
|
|
46
|
+ model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
|
|
|
47
|
+ model_T_Sys_Accessories.F_Size = file.ContentLength;
|
|
|
48
|
+ model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人
|
|
|
49
|
+ int id = new Bll.T_Sys_Accessories().Add(model_T_Sys_Accessories);
|
|
|
50
|
+ model_T_Sys_Accessories.F_FileId = id;
|
|
|
51
|
+ acs.Add(model_T_Sys_Accessories);
|
|
|
52
|
+ }
|
|
|
53
|
+ return Success("成功", acs);
|
|
|
54
|
+ }
|
|
|
55
|
+ else
|
|
|
56
|
+ {
|
|
|
57
|
+ return Error("请选择要上传的文件");
|
|
|
58
|
+ }
|
|
|
59
|
+ #endregion
|
|
|
60
|
+
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
|
63
|
+
|
|
|
64
|
+ //添加工单
|
|
|
65
|
+ /// <summary>
|
|
|
66
|
+ ///添加
|
|
|
67
|
+ /// </summary>
|
|
|
68
|
+ /// <param name="input"></param>
|
|
|
69
|
+ /// <returns></returns>
|
|
|
70
|
+ public ActionResult AddFaultRepairWorkOrder(T_FaultRepairBaseinput input)
|
|
|
71
|
+ {
|
|
|
72
|
+ Model.T_FaultRepair_Base model = new Model.T_FaultRepair_Base();
|
|
|
73
|
+ model.F_Applicant = input.Applicant;
|
|
|
74
|
+ model.F_ApplicationDept = input.ApplicationDept;
|
|
|
75
|
+ model.F_Phone = input.Phone;
|
|
|
76
|
+ model.F_Applicantsphone = input.Applicantsphone;
|
|
|
77
|
+ model.F_WorkOrderCategory = input.WorkOrderCategory;
|
|
|
78
|
+ model.F_Content = input.Content;
|
|
|
79
|
+ model.F_PlaceOfRepair = input.PlaceOfRepair;
|
|
|
80
|
+ model.F_File = input.File;
|
|
|
81
|
+ model.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
|
|
|
82
|
+
|
|
|
83
|
+ if (!string.IsNullOrEmpty(input.Maintenancer) && !string.IsNullOrEmpty(input.MaintenanceDept))
|
|
|
84
|
+ {
|
|
|
85
|
+ model.F_AssignTime = DateTime.Now;
|
|
|
86
|
+
|
|
|
87
|
+ List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_ParentID=0 and F_Name='故障报修'");
|
|
|
88
|
+ int timeout = listgd.First().F_TimeOut;
|
|
|
89
|
+ model.F_Deadline = DateTime.Now.AddHours(timeout);
|
|
|
90
|
+ model.F_MaintenanceDept = input.MaintenanceDept;
|
|
|
91
|
+ model.F_Maintenancer = input.Maintenancer;
|
|
|
92
|
+ model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
|
|
|
93
|
+ }
|
|
|
94
|
+ else
|
|
|
95
|
+ {
|
|
|
96
|
+ model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
|
|
|
97
|
+ }
|
|
|
98
|
+
|
|
|
99
|
+ model.F_CreateTime = DateTime.Now;
|
|
|
100
|
+ model.F_CreateUser = User.F_UserCode;
|
|
|
101
|
+ model.F_CreateUserDept = User.F_DeptId.ToString();
|
|
|
102
|
+
|
|
|
103
|
+ if (baseBll.Add(model) > 0)
|
|
|
104
|
+ {
|
|
|
105
|
+ AddAddlog(model.F_WorkOrderCode);
|
|
|
106
|
+
|
|
|
107
|
+ if (!string.IsNullOrEmpty(input.Maintenancer) && !string.IsNullOrEmpty(input.MaintenanceDept))
|
|
|
108
|
+ {
|
|
|
109
|
+ AddAssignlog(model.F_WorkOrderCode, input.Maintenancer);
|
|
|
110
|
+
|
|
|
111
|
+ }
|
|
|
112
|
+ return Success("添加成功!");
|
|
|
113
|
+ }
|
|
|
114
|
+ else return Error("添加失败!");
|
|
|
115
|
+
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
|
118
|
+
|
|
|
119
|
+ //查收
|
|
|
120
|
+ public ActionResult CheckWorkOrder(string WorkOrderCode)
|
|
|
121
|
+ {
|
|
|
122
|
+ Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
|
|
|
123
|
+ if (model != null)
|
|
|
124
|
+ {
|
|
|
125
|
+ if (model.F_Maintenancer == User.F_UserCode)
|
|
|
126
|
+ {
|
|
|
127
|
+ model.F_UpdateTime = DateTime.Now;
|
|
|
128
|
+ model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.dealing;
|
|
|
129
|
+ AddOperatorLog("查收了工单", (int)EnumOperatorType.check, model.F_WorkOrderCode);
|
|
|
130
|
+
|
|
|
131
|
+ return Success(" 查收成功!");
|
|
|
132
|
+ }
|
|
|
133
|
+ else
|
|
|
134
|
+ {
|
|
|
135
|
+ return Error("你没有权限查收!");
|
|
|
136
|
+ }
|
|
|
137
|
+ }
|
|
|
138
|
+ return Error("工单不存在!");
|
|
|
139
|
+ }
|
|
|
140
|
+
|
|
|
141
|
+ //退单
|
|
|
142
|
+ public ActionResult BackWorkOrder(string WorkOrderCode)
|
|
|
143
|
+ {
|
|
|
144
|
+ Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
|
|
|
145
|
+ if (model != null)
|
|
|
146
|
+ {
|
|
|
147
|
+ if (model.F_Maintenancer == User.F_UserCode)
|
|
|
148
|
+ {
|
|
|
149
|
+ model.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
|
|
|
150
|
+ model.F_Maintenancer = "";
|
|
|
151
|
+ model.F_MaintenanceDept = "";
|
|
|
152
|
+ model.F_AssignTime = null;
|
|
|
153
|
+ model.F_UpdateTime = DateTime.Now;
|
|
|
154
|
+ model.F_Deadline = null;
|
|
|
155
|
+ AddOperatorLog("退回了工单", (int)EnumOperatorType.back, model.F_WorkOrderCode);
|
|
|
156
|
+
|
|
|
157
|
+ return Success(" 退回成功!");
|
|
|
158
|
+ }
|
|
|
159
|
+ else
|
|
|
160
|
+ {
|
|
|
161
|
+ return Error("你没有权限退回!");
|
|
|
162
|
+ }
|
|
|
163
|
+ }
|
|
|
164
|
+ return Error("工单不存在!");
|
|
|
165
|
+ }
|
|
|
166
|
+
|
|
|
167
|
+
|
|
|
168
|
+
|
|
|
169
|
+ //处理完成 //异常完结
|
|
|
170
|
+
|
|
|
171
|
+
|
|
|
172
|
+ //协助.内外协助都生成新工单
|
|
|
173
|
+ //Type 0是内部协助 1是外部协助
|
|
|
174
|
+ public ActionResult AssistWorkOrder(string WorkOrderCode,string WorkOrderCategory, string Maintenancer,string Content,int Type)
|
|
|
175
|
+ {
|
|
|
176
|
+ Model.T_FaultRepair_Base model = baseBll.GetModel(WorkOrderCode);
|
|
|
177
|
+ Model.T_FaultRepair_Base newmodel = new Model.T_FaultRepair_Base();
|
|
|
178
|
+ if (Type == 0)
|
|
|
179
|
+ {
|
|
|
180
|
+ if (!string.IsNullOrEmpty(Maintenancer))
|
|
|
181
|
+ {
|
|
|
182
|
+ return Error("请选择维修人");
|
|
|
183
|
+ }
|
|
|
184
|
+
|
|
|
185
|
+
|
|
|
186
|
+ newmodel.F_Applicant = model.F_Applicant;
|
|
|
187
|
+ newmodel.F_Applicantsphone = model.F_Applicantsphone;
|
|
|
188
|
+ newmodel.F_ApplicationDept = model.F_ApplicationDept;
|
|
|
189
|
+ newmodel.F_Phone = model.F_Phone;
|
|
|
190
|
+ newmodel.F_WorkOrderCategory = WorkOrderCategory;
|
|
|
191
|
+ newmodel.F_Content = Content;
|
|
|
192
|
+ newmodel.F_PlaceOfRepair = model.F_PlaceOfRepair;
|
|
|
193
|
+
|
|
|
194
|
+ newmodel.F_Maintenancer = Maintenancer;
|
|
|
195
|
+ newmodel.F_MaintenanceDept = model.F_MaintenanceDept;
|
|
|
196
|
+ newmodel.F_AssignTime = DateTime.Now;
|
|
|
197
|
+ newmodel.F_File = model.F_File;
|
|
|
198
|
+
|
|
|
199
|
+ List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_ParentID=0 and F_Name='故障报修'");
|
|
|
200
|
+ int timeout = listgd.First().F_TimeOut;
|
|
|
201
|
+ newmodel.F_Deadline = DateTime.Now.AddHours(timeout);
|
|
|
202
|
+
|
|
|
203
|
+ newmodel.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.receive;
|
|
|
204
|
+ newmodel.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
|
|
|
205
|
+
|
|
|
206
|
+ newmodel.F_CreateTime = DateTime.Now;
|
|
|
207
|
+ newmodel.F_CreateUser = User.F_UserCode;
|
|
|
208
|
+ newmodel.F_CreateUserDept = User.F_DeptId.ToString();
|
|
|
209
|
+ if (baseBll.Add(newmodel) > 0)
|
|
|
210
|
+ {
|
|
|
211
|
+ AddAddlog(newmodel.F_WorkOrderCode);
|
|
|
212
|
+
|
|
|
213
|
+ if (!string.IsNullOrEmpty(Maintenancer))
|
|
|
214
|
+ {
|
|
|
215
|
+ AddAssignlog(newmodel.F_WorkOrderCode, Maintenancer);
|
|
|
216
|
+ }
|
|
|
217
|
+ //更新model
|
|
|
218
|
+
|
|
|
219
|
+ model.F_InternalWorkOrderCode = newmodel.F_WorkOrderCode;
|
|
|
220
|
+ model.F_UpdateTime = DateTime.Now;
|
|
|
221
|
+ baseBll.Update(model);
|
|
|
222
|
+
|
|
|
223
|
+ AddInternalasslog(model.F_WorkOrderCode, newmodel.F_WorkOrderCode);
|
|
|
224
|
+
|
|
|
225
|
+ return Success("添加成功!");
|
|
|
226
|
+ }
|
|
|
227
|
+ else return Error("添加失败!");
|
|
|
228
|
+
|
|
|
229
|
+
|
|
|
230
|
+
|
|
|
231
|
+
|
|
|
232
|
+ }
|
|
|
233
|
+ //外协作
|
|
|
234
|
+ else
|
|
|
235
|
+ {
|
|
|
236
|
+ newmodel.F_Applicant = model.F_Applicant;
|
|
|
237
|
+ newmodel.F_Applicantsphone = model.F_Applicantsphone;
|
|
|
238
|
+ newmodel.F_ApplicationDept = model.F_ApplicationDept;
|
|
|
239
|
+ newmodel.F_Phone = model.F_Phone;
|
|
|
240
|
+
|
|
|
241
|
+ newmodel.F_WorkOrderCategory = WorkOrderCategory;
|
|
|
242
|
+ newmodel.F_Content = Content;
|
|
|
243
|
+ newmodel.F_PlaceOfRepair = model.F_PlaceOfRepair;
|
|
|
244
|
+
|
|
|
245
|
+ newmodel.F_Maintenancer = Maintenancer;
|
|
|
246
|
+ newmodel.F_MaintenanceDept = model.F_MaintenanceDept;
|
|
|
247
|
+
|
|
|
248
|
+ newmodel.F_File = model.F_File;
|
|
|
249
|
+
|
|
|
250
|
+ newmodel.F_WorkOrderState = (int)EnumFaultRepairWorkOrderState.neworder;
|
|
|
251
|
+ newmodel.F_WorkOrderCode = DateTime.Now.ToString("yyyyMMddHHmmssfff");//工单编号
|
|
|
252
|
+
|
|
|
253
|
+ newmodel.F_CreateTime = DateTime.Now;
|
|
|
254
|
+ newmodel.F_CreateUser = User.F_UserCode;
|
|
|
255
|
+ newmodel.F_CreateUserDept = User.F_DeptId.ToString();
|
|
|
256
|
+ if (baseBll.Add(newmodel) > 0)
|
|
|
257
|
+ {
|
|
|
258
|
+ AddOperatorLog("创建了工单", (int)EnumOperatorType.add, newmodel.F_WorkOrderCode);
|
|
|
259
|
+
|
|
|
260
|
+ //更新原来的工单model
|
|
|
261
|
+
|
|
|
262
|
+ model.F_ExternalWorkOrderCode = newmodel.F_WorkOrderCode;
|
|
|
263
|
+ model.F_UpdateTime = DateTime.Now;
|
|
|
264
|
+ baseBll.Update(model);
|
|
|
265
|
+
|
|
|
266
|
+ AddExternalasslog(model.F_WorkOrderCode, newmodel.F_WorkOrderCode);
|
|
|
267
|
+
|
|
|
268
|
+ return Success("添加成功!");
|
|
|
269
|
+ }
|
|
|
270
|
+ else return Error("添加失败!");
|
|
|
271
|
+
|
|
|
272
|
+ }
|
|
|
273
|
+
|
|
|
274
|
+
|
|
|
275
|
+ }
|
|
|
276
|
+
|
|
|
277
|
+
|
|
|
278
|
+ //维修员的列表 待接单 待完成 已完成
|
|
|
279
|
+ //报修人的列表 已上报 已完结
|
|
|
280
|
+ //工单详情
|
|
|
281
|
+ //评价
|
|
|
282
|
+ // 返修
|
|
|
283
|
+
|
|
|
284
|
+ // 添加操作记录
|
|
|
285
|
+ public bool AddOperatorLog(string content,int type,string workordercode)
|
|
|
286
|
+ {
|
|
|
287
|
+ Model.T_FaultRepair_OperationLog model = new Model.T_FaultRepair_OperationLog();
|
|
|
288
|
+ model.F_LogContent = content;
|
|
|
289
|
+ model.F_OperationTime = DateTime.Now;
|
|
|
290
|
+ model.F_OperationType = type;
|
|
|
291
|
+ model.F_Operator = User.F_UserCode;
|
|
|
292
|
+ model.F_WorkOrderCode = workordercode;
|
|
|
293
|
+ logBll.Add(model);
|
|
|
294
|
+ return true;
|
|
|
295
|
+ }
|
|
|
296
|
+
|
|
|
297
|
+ public void AddAddlog(string workordercode)
|
|
|
298
|
+ {
|
|
|
299
|
+ AddOperatorLog("创建了工单", (int)EnumOperatorType.add, workordercode);
|
|
|
300
|
+ }
|
|
|
301
|
+
|
|
|
302
|
+ public void AddAssignlog(string workordercode,string maintenancer)
|
|
|
303
|
+ {
|
|
|
304
|
+ AddOperatorLog("指派工单给" + maintenancer, (int)EnumOperatorType.assign, workordercode);
|
|
|
305
|
+
|
|
|
306
|
+ }
|
|
|
307
|
+ public void AddInternalasslog(string workordercode, string newworkordercode)
|
|
|
308
|
+ {
|
|
|
309
|
+
|
|
|
310
|
+ AddOperatorLog("创建内协作工单" + newworkordercode, (int)EnumOperatorType.internalassistance, workordercode);
|
|
|
311
|
+ }
|
|
|
312
|
+ public void AddExternalasslog(string workordercode, string newworkordercode)
|
|
|
313
|
+ {
|
|
|
314
|
+ AddOperatorLog("创建外协作工单" + newworkordercode, (int)EnumOperatorType.externalassistance, workordercode);
|
|
|
315
|
+
|
|
|
316
|
+ }
|
|
|
317
|
+
|
|
|
318
|
+
|
|
|
319
|
+
|
|
|
320
|
+ }
|
|
|
321
|
+}
|