|
|
@@ -1,5 +1,7 @@
|
|
1
|
1
|
using CallCenter.Utility;
|
|
|
2
|
+using CallCenterApi.DB;
|
|
2
|
3
|
using CallCenterApi.Interface.Controllers.Base;
|
|
|
4
|
+using CallCenterApi.Interface.Models.Enum;
|
|
3
|
5
|
using CallCenterApi.Interface.Models.Input;
|
|
4
|
6
|
using System;
|
|
5
|
7
|
using System.Collections.Generic;
|
|
|
@@ -17,13 +19,16 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
17
|
19
|
BLL.T_Cus_CustomerBaseNew cusbll = new BLL.T_Cus_CustomerBaseNew();
|
|
18
|
20
|
BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
|
|
19
|
21
|
BLL.T_Wo_MaterialManage mmBLL = new BLL.T_Wo_MaterialManage();
|
|
|
22
|
+ BLL.T_Wo_WorkOrderItem_New itembll = new BLL.T_Wo_WorkOrderItem_New();
|
|
|
23
|
+ BLL.T_Wo_WorkOrder_Logs blllogs = new BLL.T_Wo_WorkOrder_Logs();
|
|
|
24
|
+ BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
|
|
20
|
25
|
// GET: WorkOrderNew
|
|
21
|
26
|
/// <summary>
|
|
22
|
27
|
/// 获取工单列表
|
|
23
|
28
|
/// </summary>
|
|
24
|
29
|
/// <returns></returns>
|
|
25
|
|
- public ActionResult GetList(string code,int type, string cusname, string cusphone, string companyname, string province, string city,
|
|
26
|
|
- string country, string township, int pageindex = 1, int pagesize = 10)
|
|
|
30
|
+ public ActionResult GetList(string code, string cusname, string cusphone, string companyname, string province, string city,
|
|
|
31
|
+ string country, string township, string touser, int type = 0, int state=-1, int pageindex = 1,int pagesize = 10)
|
|
27
|
32
|
{
|
|
28
|
33
|
|
|
29
|
34
|
string sql = $" and F_IsDelete=0";
|
|
|
@@ -31,6 +36,10 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
31
|
36
|
#region 筛选条件
|
|
32
|
37
|
if (type > 0&& type <4)//工单类型
|
|
33
|
38
|
sql += $" and F_Type=" + type;
|
|
|
39
|
+ if (state>0)//工单状态
|
|
|
40
|
+ sql += $" and F_State=" + state;
|
|
|
41
|
+ if (!string.IsNullOrWhiteSpace(touser))//参与人
|
|
|
42
|
+ sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
|
|
34
|
43
|
if (!string.IsNullOrWhiteSpace(code))//工单编号
|
|
35
|
44
|
sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
|
|
36
|
45
|
if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
|
|
|
@@ -48,7 +57,6 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
48
|
57
|
if (!string.IsNullOrWhiteSpace(province))//乡
|
|
49
|
58
|
sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
|
|
50
|
59
|
#endregion
|
|
51
|
|
-
|
|
52
|
60
|
int recordCount = 0;
|
|
53
|
61
|
if (!string.IsNullOrWhiteSpace(sql))
|
|
54
|
62
|
{
|
|
|
@@ -63,6 +71,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
63
|
71
|
true,
|
|
64
|
72
|
out recordCount);
|
|
65
|
73
|
}
|
|
|
74
|
+
|
|
66
|
75
|
List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
|
|
67
|
76
|
List<WorkOrderNewInput> Input = modeltooip(modlelist);
|
|
68
|
77
|
var obj = new
|
|
|
@@ -78,32 +87,55 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
78
|
87
|
/// <summary>
|
|
79
|
88
|
/// 查询工单详情
|
|
80
|
89
|
/// </summary>
|
|
81
|
|
- public ActionResult GetDetails(int id)
|
|
|
90
|
+ public ActionResult GetDetails(int id)
|
|
82
|
91
|
{
|
|
83
|
|
- string sql = "";
|
|
84
|
|
- if (id >0)
|
|
85
|
|
- {
|
|
86
|
|
- sql += $" ( F_ID like '%" + id + "%' ) ";
|
|
87
|
|
- }
|
|
88
|
|
- else
|
|
89
|
|
- return Error("请输入正确的id");
|
|
90
|
|
- var list = new List<Model.T_Wo_WorkOrder>();
|
|
91
|
|
- if (!string.IsNullOrWhiteSpace(sql))
|
|
|
92
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
93
|
+ if (userId != 0)
|
|
92
|
94
|
{
|
|
93
|
|
- sql += " and F_IsDelete=0";
|
|
94
|
|
- list = workOrder.GetModelList(sql);
|
|
95
|
|
- }
|
|
96
|
|
- if (list.Count >0)
|
|
97
|
|
- {
|
|
98
|
|
- List<WorkOrderNewInput> Input = modeltooip(list);
|
|
99
|
|
- if (Input!=null )
|
|
100
|
|
- return Success("获取工单详情成功", Input.FirstOrDefault());
|
|
|
95
|
+ Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
|
|
|
96
|
+ string sql = "";
|
|
|
97
|
+ if (id > 0)
|
|
|
98
|
+ {
|
|
|
99
|
+ sql += $" ( F_ID like '%" + id + "%' ) ";
|
|
|
100
|
+ }
|
|
|
101
|
+ else
|
|
|
102
|
+ return Error("请输入正确的id");
|
|
|
103
|
+ var list = new List<Model.T_Wo_WorkOrder>();
|
|
|
104
|
+ if (!string.IsNullOrWhiteSpace(sql))
|
|
|
105
|
+ {
|
|
|
106
|
+ sql += " and F_IsDelete=0";
|
|
|
107
|
+ list = workOrder.GetModelList(sql);
|
|
|
108
|
+ }
|
|
|
109
|
+ var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + " ");
|
|
|
110
|
+
|
|
|
111
|
+ if (list.Count > 0)
|
|
|
112
|
+ {
|
|
|
113
|
+ List<WorkOrderNewInput> Input = modeltooip(list);
|
|
|
114
|
+ if (Input !=null )
|
|
|
115
|
+ {
|
|
|
116
|
+ var obj = new
|
|
|
117
|
+ {
|
|
|
118
|
+ state = "success",
|
|
|
119
|
+ message = "成功",
|
|
|
120
|
+ rows = Input,
|
|
|
121
|
+ total= itemlasts,
|
|
|
122
|
+ };
|
|
|
123
|
+
|
|
|
124
|
+ return Content(obj.ToJson());
|
|
|
125
|
+ }
|
|
|
126
|
+ else
|
|
|
127
|
+ {
|
|
|
128
|
+ return Error("没有查询到此工单");
|
|
|
129
|
+ }
|
|
|
130
|
+ }
|
|
101
|
131
|
else
|
|
102
|
132
|
return Error("没有查询到此工单");
|
|
|
133
|
+
|
|
103
|
134
|
}
|
|
104
|
135
|
else
|
|
105
|
|
- return Error("没有查询到此工单");
|
|
106
|
|
-
|
|
|
136
|
+ {
|
|
|
137
|
+ return Error("无操作权限!");
|
|
|
138
|
+ }
|
|
107
|
139
|
}
|
|
108
|
140
|
/// <summary>
|
|
109
|
141
|
/// 添加工单
|
|
|
@@ -138,76 +170,103 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
138
|
170
|
/// <returns></returns>
|
|
139
|
171
|
public ActionResult DelWorkOrder(string[] ids)
|
|
140
|
172
|
{
|
|
141
|
|
- if (ids != null && ids.Length > 0)
|
|
|
173
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
174
|
+ if (userId != 0)
|
|
142
|
175
|
{
|
|
143
|
|
- string idd = " ";
|
|
144
|
|
- foreach (string str in ids)
|
|
|
176
|
+ if (ids != null && ids.Length > 0)
|
|
145
|
177
|
{
|
|
146
|
|
- idd += str + ",";
|
|
147
|
|
- }
|
|
148
|
|
- if (!string.IsNullOrEmpty(idd.Trim()))
|
|
149
|
|
- {
|
|
150
|
|
- if (workOrder.DeleteList(idd.TrimEnd(',')))
|
|
|
178
|
+ string idd = " ";
|
|
|
179
|
+ foreach (string str in ids)
|
|
|
180
|
+ {
|
|
|
181
|
+ idd += str + ",";
|
|
|
182
|
+ }
|
|
|
183
|
+ if (!string.IsNullOrEmpty(idd.Trim()))
|
|
151
|
184
|
{
|
|
152
|
|
- return Success("设置成功");
|
|
|
185
|
+ if (workOrder.DeleteList(idd.TrimEnd(',')))
|
|
|
186
|
+ {
|
|
|
187
|
+ return Success("设置成功");
|
|
|
188
|
+ }
|
|
|
189
|
+ else
|
|
|
190
|
+ {
|
|
|
191
|
+ return Error("设置失败");
|
|
|
192
|
+ }
|
|
153
|
193
|
}
|
|
154
|
194
|
else
|
|
155
|
195
|
{
|
|
156
|
|
- return Error("设置失败");
|
|
|
196
|
+ return Error("请选择用户");
|
|
157
|
197
|
}
|
|
158
|
198
|
}
|
|
159
|
199
|
else
|
|
160
|
200
|
{
|
|
161
|
|
- return Error("请选择用户");
|
|
|
201
|
+ return Error("获取参数失败");
|
|
162
|
202
|
}
|
|
163
|
203
|
}
|
|
164
|
204
|
else
|
|
165
|
205
|
{
|
|
166
|
|
- return Error("获取参数失败");
|
|
|
206
|
+ return Error("无操作权限!");
|
|
|
207
|
+ }
|
|
167
|
208
|
}
|
|
168
|
|
- }
|
|
169
|
209
|
/// <summary>
|
|
170
|
210
|
/// 修改工单
|
|
171
|
211
|
/// </summary>
|
|
172
|
212
|
/// <returns></returns>
|
|
173
|
213
|
public ActionResult Update(WorkOrderNewInput input)
|
|
174
|
214
|
{
|
|
175
|
|
- string usercode = CurrentUser.UserData.F_UserCode;
|
|
176
|
|
- #region 添加验证判断
|
|
177
|
|
- if (input.F_ID <= 0)
|
|
178
|
|
- return Error("参数错误!");
|
|
179
|
|
- if (!(input.F_Type > 0 && input.F_Type < 4))
|
|
180
|
|
- return Error("工单类型错误!");
|
|
181
|
|
- if (input.F_Type==1|| input.F_Type == 3)
|
|
|
215
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
216
|
+ if (userId != 0)
|
|
182
|
217
|
{
|
|
183
|
|
- if (input.F_CustomerID>0)
|
|
|
218
|
+ string usercode = CurrentUser.UserData.F_UserCode;
|
|
|
219
|
+ Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
|
|
|
220
|
+ #region 添加验证判断
|
|
|
221
|
+ if (input.F_ID <= 0)
|
|
|
222
|
+ return Error("参数错误!");
|
|
|
223
|
+ if (!(input.F_Type > 0 && input.F_Type < 4))
|
|
|
224
|
+ return Error("工单类型错误!");
|
|
|
225
|
+ if (input.F_Type == 1 || input.F_Type == 3)
|
|
184
|
226
|
{
|
|
185
|
|
- if (!valcode(input.F_CustomerID.ToString(), 10))
|
|
|
227
|
+ if (input.F_CustomerID > 0)
|
|
186
|
228
|
{
|
|
187
|
|
- return Error("客户编号为10为纯数字!");
|
|
|
229
|
+ if (!valcode(input.F_CustomerID.ToString(), 10))
|
|
|
230
|
+ {
|
|
|
231
|
+ return Error("客户编号为10为纯数字!");
|
|
|
232
|
+ }
|
|
188
|
233
|
}
|
|
|
234
|
+ if (input.F_MaterialID > 0)
|
|
|
235
|
+ {
|
|
|
236
|
+ if (!valcode(input.F_MaterialID.ToString(), 11))
|
|
|
237
|
+ {
|
|
|
238
|
+ return Error("物料编码为11为纯数字!");
|
|
|
239
|
+ }
|
|
|
240
|
+ }
|
|
|
241
|
+
|
|
189
|
242
|
}
|
|
190
|
|
- if (input.F_MaterialID>0)
|
|
|
243
|
+ #endregion
|
|
|
244
|
+ var model = workOrder.GetModel(input.F_ID);
|
|
|
245
|
+ #region 保存客户基本信息
|
|
|
246
|
+ model = inputtoobj(model, input);
|
|
|
247
|
+ #endregion
|
|
|
248
|
+ bool n = workOrder.Update(model);
|
|
|
249
|
+ if (n)
|
|
191
|
250
|
{
|
|
192
|
|
- if (!valcode(input.F_MaterialID.ToString(), 11))
|
|
|
251
|
+ WriteWorkOrderLog(model.F_WorkOrderCode, ua.F_UserCode, 0, "", 1, "修改工单");
|
|
|
252
|
+ #region 读取当前登录人的部门
|
|
|
253
|
+ string deptname = "";
|
|
|
254
|
+ var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
|
|
|
255
|
+ if (deptmodel != null)
|
|
193
|
256
|
{
|
|
194
|
|
- return Error("物料编码为11为纯数字!");
|
|
|
257
|
+ deptname = deptmodel.F_DeptName + "-";
|
|
195
|
258
|
}
|
|
|
259
|
+ #endregion
|
|
|
260
|
+ AddLog(input.F_ID, model.F_State.Value, deptname + ua.F_UserName + "(" + ua.F_UserCode + ")" + "修改工单", (int)EnumItemType.update, (int)EnumItemOpt.update, "", 0, ua,0,0);
|
|
|
261
|
+ return Success("保存成功!");
|
|
196
|
262
|
}
|
|
197
|
|
-
|
|
|
263
|
+ else
|
|
|
264
|
+ return Error("保存失败!");
|
|
198
|
265
|
}
|
|
199
|
|
- #endregion
|
|
200
|
|
- var model = workOrder.GetModel(input.F_ID);
|
|
201
|
|
- #region 保存客户基本信息
|
|
202
|
|
- model = inputtoobj(model, input);
|
|
203
|
|
- #endregion
|
|
204
|
|
- bool n = workOrder.Update(model);
|
|
205
|
|
- if (n)
|
|
|
266
|
+ else
|
|
206
|
267
|
{
|
|
207
|
|
- return Success("保存成功!");
|
|
|
268
|
+ return Error("无操作权限!");
|
|
208
|
269
|
}
|
|
209
|
|
- else
|
|
210
|
|
- return Error("保存失败!");
|
|
211
|
270
|
}
|
|
212
|
271
|
/// <summary>
|
|
213
|
272
|
/// 验证物料编码为10位纯数字
|
|
|
@@ -311,9 +370,24 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
311
|
370
|
model.F_CJ_Tonnage = model1[i].F_CJ_Tonnage;//抽检-抽检吨数
|
|
312
|
371
|
model.F_CJ_BagNo = model1[i].F_CJ_BagNo;//抽检-抽检袋数
|
|
313
|
372
|
model.F_CJ_Outlay = model1[i].F_CJ_Outlay;//抽检-公关费用金额:单位元
|
|
|
373
|
+ model.F_State = model1[i].F_State;//工单状态
|
|
|
374
|
+ model.F_DealBy = model1[i].F_DealBy;//处理人
|
|
|
375
|
+ model.F_DealTime = model1[i].F_DealTime;//处理时间
|
|
|
376
|
+ model.F_DealContent = model1[i].F_DealContent;//处理内容
|
|
|
377
|
+ model.F_DealResult = model1[i].F_DealResult;//处理结果
|
|
|
378
|
+ model.F_DealReasons = model1[i].F_DealReasons;//未处理原因
|
|
|
379
|
+ model.F_CreateBy = model1[i].F_CreateBy;//添加人工号
|
|
|
380
|
+ if (TimeforOver(model1[i].F_ID ))
|
|
|
381
|
+ {
|
|
|
382
|
+ model.F_IsOver = 0;
|
|
|
383
|
+ }
|
|
|
384
|
+ else
|
|
|
385
|
+ {
|
|
|
386
|
+ model.F_IsOver = 1;
|
|
|
387
|
+ }
|
|
314
|
388
|
#endregion
|
|
315
|
389
|
Input.Add(model);
|
|
316
|
|
-
|
|
|
390
|
+
|
|
317
|
391
|
}
|
|
318
|
392
|
|
|
319
|
393
|
return Input;
|
|
|
@@ -325,6 +399,60 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
325
|
399
|
|
|
326
|
400
|
}
|
|
327
|
401
|
/// <summary>
|
|
|
402
|
+ /// 是否超时
|
|
|
403
|
+ /// </summary>
|
|
|
404
|
+ /// <param name="id"></param>
|
|
|
405
|
+ /// <returns></returns>
|
|
|
406
|
+ private bool TimeforOver(int id)
|
|
|
407
|
+ {
|
|
|
408
|
+ var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + id + " ");
|
|
|
409
|
+ string time1="", time2="" ;
|
|
|
410
|
+ int time = 0;
|
|
|
411
|
+ if (itemlasts.Count > 0)
|
|
|
412
|
+ {
|
|
|
413
|
+ foreach (var it in itemlasts)
|
|
|
414
|
+ {
|
|
|
415
|
+ if (it.F_WoState >= 2)
|
|
|
416
|
+ {
|
|
|
417
|
+ if (it.F_WoState == 2)
|
|
|
418
|
+ {
|
|
|
419
|
+ time1 = it.F_CreateTime.ToString();
|
|
|
420
|
+ time =int .Parse ( it.F_LimitTime);
|
|
|
421
|
+ }
|
|
|
422
|
+ if (it.F_WoState==10)
|
|
|
423
|
+ {
|
|
|
424
|
+ time2 = it.F_CreateTime.ToString();
|
|
|
425
|
+ }
|
|
|
426
|
+ if (time2!="")
|
|
|
427
|
+ {
|
|
|
428
|
+ int a= (DateTime.Parse(time2) - DateTime.Parse(time1)).Hours ;
|
|
|
429
|
+ if (a > time)
|
|
|
430
|
+ {
|
|
|
431
|
+ return false;
|
|
|
432
|
+ }
|
|
|
433
|
+ }
|
|
|
434
|
+ else
|
|
|
435
|
+ {
|
|
|
436
|
+ int a = (DateTime.Now - DateTime.Parse(time1)).Hours;
|
|
|
437
|
+ if (a > time)
|
|
|
438
|
+ {
|
|
|
439
|
+ return false;
|
|
|
440
|
+ }
|
|
|
441
|
+ }
|
|
|
442
|
+ }
|
|
|
443
|
+ else
|
|
|
444
|
+ {
|
|
|
445
|
+ return true ;
|
|
|
446
|
+ }
|
|
|
447
|
+ }
|
|
|
448
|
+ }
|
|
|
449
|
+ else
|
|
|
450
|
+ {
|
|
|
451
|
+ return true;
|
|
|
452
|
+ }
|
|
|
453
|
+ return true;
|
|
|
454
|
+ }
|
|
|
455
|
+ /// <summary>
|
|
328
|
456
|
/// 根据传入的对象和input的内容返回对象(添加修改使用)
|
|
329
|
457
|
/// </summary>
|
|
330
|
458
|
private Model.T_Wo_WorkOrder inputtoobj(Model.T_Wo_WorkOrder model, WorkOrderNewInput input)
|
|
|
@@ -377,18 +505,598 @@ namespace CallCenterApi.Interface.Controllers.workorder
|
|
377
|
505
|
model.F_CJ_TestUnit = input.F_CJ_TestUnit;//抽检-化验单位
|
|
378
|
506
|
model.F_CJ_Tonnage = input.F_CJ_Tonnage;//抽检-抽检吨数
|
|
379
|
507
|
model.F_CJ_BagNo = input.F_CJ_BagNo;//抽检-抽检袋数
|
|
380
|
|
- model.F_CJ_Outlay = input.F_CJ_Outlay;//抽检-公关费用金额:单位元
|
|
|
508
|
+ model.F_CJ_Outlay = input.F_CJ_Outlay;//抽检-公关费用金额:单位元】
|
|
|
509
|
+ if (input.F_State != null )
|
|
|
510
|
+ {
|
|
|
511
|
+ model.F_State = input.F_State;//抽检-公关费用金额:单位元】
|
|
|
512
|
+ }
|
|
|
513
|
+ else
|
|
|
514
|
+ {
|
|
|
515
|
+ model.F_State = (int)EnumWorkOrderState.neworder;
|
|
|
516
|
+ }
|
|
|
517
|
+
|
|
381
|
518
|
#endregion
|
|
382
|
519
|
return model;
|
|
383
|
520
|
}
|
|
384
|
521
|
/// <summary>
|
|
385
|
|
- /// 获取工单详情
|
|
|
522
|
+ /// 添加工单记录
|
|
|
523
|
+ /// </summary>
|
|
|
524
|
+ public long AddLog(long woid, int wostate, string content, int itemtype, int opttype, string nextuser, int nextdept, Model.T_Sys_UserAccount nowUser ,int overtime,int sms )
|
|
|
525
|
+ {
|
|
|
526
|
+ Model.T_Wo_WorkOrderItem_New itemModel = new Model.T_Wo_WorkOrderItem_New();
|
|
|
527
|
+ #region
|
|
|
528
|
+ //处理当前工单的记录之前的记录过期
|
|
|
529
|
+ var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_ItemType=" + itemtype + " and F_WoID=" + woid + " ");
|
|
|
530
|
+ if (itemlast.Count > 0)
|
|
|
531
|
+ {
|
|
|
532
|
+ foreach (var it in itemlast)
|
|
|
533
|
+ {
|
|
|
534
|
+ it.F_IsUsed = 1;
|
|
|
535
|
+ it.F_LimitTime = overtime.ToString();
|
|
|
536
|
+ itembll.Update(it);
|
|
|
537
|
+ }
|
|
|
538
|
+ }
|
|
|
539
|
+ #endregion
|
|
|
540
|
+ itemModel.F_WoID = woid;
|
|
|
541
|
+ itemModel.F_IsSMS = sms;
|
|
|
542
|
+ itemModel.F_WoState = wostate;
|
|
|
543
|
+ itemModel.F_ItemType = itemtype;
|
|
|
544
|
+ itemModel.F_OptType = opttype;
|
|
|
545
|
+ itemModel.F_OptContent = content;
|
|
|
546
|
+ itemModel.F_NextUser = nextuser;
|
|
|
547
|
+ itemModel.F_NextDept = nextdept;
|
|
|
548
|
+ itemModel.F_IsUsed = 0;
|
|
|
549
|
+ itemModel.F_LimitTime = overtime.ToString ();
|
|
|
550
|
+ itemModel.F_CreateUser = nowUser.F_UserCode;
|
|
|
551
|
+ itemModel.F_CreateTime = DateTime.Now;
|
|
|
552
|
+ var res = itembll.Add(itemModel);
|
|
|
553
|
+ return res;
|
|
|
554
|
+ }
|
|
|
555
|
+ public void WriteWorkOrderLog(string WorkOrderID, string UserCode, int IsDelete, string DelUserCode, int TypeId, string Remark)
|
|
|
556
|
+ {
|
|
|
557
|
+ var model = new Model.T_Wo_WorkOrder_Logs();
|
|
|
558
|
+ model.WorkOrderID = WorkOrderID; //工单编号
|
|
|
559
|
+ model.UserCode = UserCode; //修改人code
|
|
|
560
|
+ model.AddTime = DateTime.Now; //添加时间
|
|
|
561
|
+ model.IsDelete = IsDelete; //是否删除(0正常1删除)
|
|
|
562
|
+ model.DelUserCode = DelUserCode; //删除人code
|
|
|
563
|
+ model.TypeId = TypeId; //类型(0添加,1修改)
|
|
|
564
|
+ model.Remark = Remark; //备注
|
|
|
565
|
+ blllogs.Add(model);
|
|
|
566
|
+ }
|
|
|
567
|
+ /// <summary>
|
|
|
568
|
+ /// 指派/转派工单
|
|
|
569
|
+ /// <param name="orderid">工单编号</param>
|
|
|
570
|
+ /// <param name="cont">指派说明</param>
|
|
|
571
|
+ /// <param name="clbm">指派部门</param>
|
|
|
572
|
+ /// <param name="clid">指派人</param>
|
|
|
573
|
+ /// </summary>
|
|
|
574
|
+ /// <returns></returns>
|
|
|
575
|
+ [Authority]
|
|
|
576
|
+ public ActionResult AssignWorkOrder(long orderid, string cont,int overtime=0,int sms=0,int clbm = 0, int clid = 0)
|
|
|
577
|
+ {
|
|
|
578
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
579
|
+ string usercode = CurrentUser.UserData.F_UserCode;
|
|
|
580
|
+ if (userId != 0)
|
|
|
581
|
+ {
|
|
|
582
|
+ Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
|
|
|
583
|
+ if (ua != null)
|
|
|
584
|
+ {
|
|
|
585
|
+ if (clbm != 0 && clid == 0)
|
|
|
586
|
+ return Error("请选择接收人");
|
|
|
587
|
+ Model.T_Wo_WorkOrder model = workOrder.GetModel(orderid);
|
|
|
588
|
+ if (model != null)
|
|
|
589
|
+ {
|
|
|
590
|
+ var res = AssignWO(ua, model, cont, clbm, clid, overtime, sms);
|
|
|
591
|
+ if (res)
|
|
|
592
|
+ return Success("转派成功");
|
|
|
593
|
+ else
|
|
|
594
|
+ return Error("转派失败!");
|
|
|
595
|
+ }
|
|
|
596
|
+ else
|
|
|
597
|
+ return Error("工单不存在!");
|
|
|
598
|
+ }
|
|
|
599
|
+ }
|
|
|
600
|
+ return Error("无操作权限!");
|
|
|
601
|
+ }
|
|
|
602
|
+ /// <summary>
|
|
|
603
|
+ /// 接单 - 确认工单
|
|
|
604
|
+ /// </summary>
|
|
|
605
|
+ /// <returns></returns>
|
|
|
606
|
+ [Authority]
|
|
|
607
|
+ public ActionResult SureWorkOrder(long orderid)
|
|
|
608
|
+ {
|
|
|
609
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
610
|
+ if (userId != 0)
|
|
|
611
|
+ {
|
|
|
612
|
+ Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
|
|
|
613
|
+ if (ua != null)
|
|
|
614
|
+ {
|
|
|
615
|
+ Model.T_Wo_WorkOrder model = workOrder.GetModel(orderid);
|
|
|
616
|
+ if (model != null)
|
|
|
617
|
+ {
|
|
|
618
|
+ var res = SureWO(ua, model);
|
|
|
619
|
+ if (res)
|
|
|
620
|
+ return Success("接单成功");
|
|
|
621
|
+ else
|
|
|
622
|
+ return Error("接单失败");
|
|
|
623
|
+ }
|
|
|
624
|
+ else
|
|
|
625
|
+ return Error("工单不存在");
|
|
|
626
|
+ }
|
|
|
627
|
+ }
|
|
|
628
|
+ return Error("无操作权限");
|
|
|
629
|
+ }
|
|
|
630
|
+ /// <summary>
|
|
|
631
|
+ /// 处理工单信息
|
|
|
632
|
+ /// </summary>
|
|
|
633
|
+ /// <returns></returns>
|
|
|
634
|
+ [Authority]
|
|
|
635
|
+ public ActionResult DealWorkOrder(long orderid, string cont,string uncont="", int isover = 0)
|
|
|
636
|
+ {
|
|
|
637
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
638
|
+ if (userId != 0)
|
|
|
639
|
+ {
|
|
|
640
|
+ Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
|
|
|
641
|
+ if (ua != null)
|
|
|
642
|
+ {
|
|
|
643
|
+ Model.T_Wo_WorkOrder model = workOrder.GetModel(orderid);
|
|
|
644
|
+ if (model != null)
|
|
|
645
|
+ {
|
|
|
646
|
+ var res = DealWO(ua, model, cont, isover, uncont);
|
|
|
647
|
+ if (res)
|
|
|
648
|
+ return Success("处理成功");
|
|
|
649
|
+ else
|
|
|
650
|
+ return Error("处理失败!");
|
|
|
651
|
+ }
|
|
|
652
|
+ else
|
|
|
653
|
+ return Error("工单不存在!");
|
|
|
654
|
+ }
|
|
|
655
|
+ }
|
|
|
656
|
+ return Error("无操作权限!");
|
|
|
657
|
+ }
|
|
|
658
|
+ /// <summary>
|
|
|
659
|
+ /// 退回工单
|
|
|
660
|
+ /// </summary>
|
|
|
661
|
+ /// <param name="input"></param>
|
|
|
662
|
+ /// <returns></returns>
|
|
|
663
|
+ [Authority]
|
|
|
664
|
+ public ActionResult BackWorkOrder(long orderid, string cont, int type = 0)
|
|
|
665
|
+ {//办理人员和监管可以退回工单
|
|
|
666
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
667
|
+ if (userId != 0)
|
|
|
668
|
+ {
|
|
|
669
|
+ Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
|
|
|
670
|
+ if (ua != null)
|
|
|
671
|
+ {
|
|
|
672
|
+ Model.T_Wo_WorkOrder model = workOrder .GetModel(orderid);
|
|
|
673
|
+ //验证信息
|
|
|
674
|
+ if (model != null)
|
|
|
675
|
+ {
|
|
|
676
|
+ var res = BackWO(ua, model, cont, type);
|
|
|
677
|
+ if (res)
|
|
|
678
|
+ return Success("退回成功");
|
|
|
679
|
+ else
|
|
|
680
|
+ return Error("退回失败!");
|
|
|
681
|
+ }
|
|
|
682
|
+ return Error("工单不存在");
|
|
|
683
|
+ }
|
|
|
684
|
+ }
|
|
|
685
|
+ return Error("无操作权限");
|
|
|
686
|
+ }
|
|
|
687
|
+ /// <summary>
|
|
|
688
|
+ ///延期工单
|
|
386
|
689
|
/// </summary>
|
|
387
|
690
|
/// <returns></returns>
|
|
388
|
|
- public ActionResult GetDetailes()
|
|
|
691
|
+ [Authority]
|
|
|
692
|
+ public ActionResult DelayWorkOrder(long orderid, string cont, int limit = 0)
|
|
|
693
|
+ {
|
|
|
694
|
+ //办理人员和监管可以延期工单
|
|
|
695
|
+ int userId = CurrentUser.UserData.F_UserId;
|
|
|
696
|
+ if (userId != 0)
|
|
|
697
|
+ {
|
|
|
698
|
+ Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
|
|
|
699
|
+ if (ua != null)
|
|
|
700
|
+ {
|
|
|
701
|
+ Model.T_Wo_WorkOrder model = workOrder.GetModel(orderid);
|
|
|
702
|
+ //验证信息
|
|
|
703
|
+ if (model != null)
|
|
|
704
|
+ {
|
|
|
705
|
+ var res = DeWO(ua, model, cont, limit);
|
|
|
706
|
+ if (res)
|
|
|
707
|
+ return Success("延期成功");
|
|
|
708
|
+ else
|
|
|
709
|
+ return Error("延期失败!");
|
|
|
710
|
+ }
|
|
|
711
|
+ return Error("工单不存在");
|
|
|
712
|
+ }
|
|
|
713
|
+ }
|
|
|
714
|
+ return Error("无操作权限");
|
|
|
715
|
+
|
|
|
716
|
+ }
|
|
|
717
|
+ /// <summary>
|
|
|
718
|
+ /// 延期工单
|
|
|
719
|
+ /// </summary>
|
|
|
720
|
+ public bool DeWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont, int limit)
|
|
|
721
|
+ {
|
|
|
722
|
+ #region 工单处理
|
|
|
723
|
+ int sms = 0; int wostate = 0; int optbut = 0;int time = 0;
|
|
|
724
|
+ var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
|
|
|
725
|
+ if (itemlasts.Count > 0)
|
|
|
726
|
+ {
|
|
|
727
|
+ foreach (var it in itemlasts)
|
|
|
728
|
+ {
|
|
|
729
|
+ if (it.F_WoState == 1)
|
|
|
730
|
+ {
|
|
|
731
|
+ sms = int.Parse(it.F_IsSMS.ToString());
|
|
|
732
|
+ time = int.Parse(it.F_LimitTime);
|
|
|
733
|
+ }
|
|
|
734
|
+ itembll.Update(it);
|
|
|
735
|
+ wostate = int.Parse(it.F_WoState.ToString());
|
|
|
736
|
+ optbut = int.Parse(it.F_OptType.ToString());
|
|
|
737
|
+ }
|
|
|
738
|
+ }
|
|
|
739
|
+ #region 读取当前登录人部门
|
|
|
740
|
+ string deptname = "";
|
|
|
741
|
+ var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
|
|
|
742
|
+ if (deptmodel != null)
|
|
|
743
|
+ {
|
|
|
744
|
+ deptname = deptmodel.F_DeptName + "-";
|
|
|
745
|
+ }
|
|
|
746
|
+ #endregion
|
|
|
747
|
+ var content = deptname + nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + "延期工单,延期说明:" + cont;
|
|
|
748
|
+ //获取上一级处理人员
|
|
|
749
|
+ var touser = "";
|
|
|
750
|
+ var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_CreateTime desc").FirstOrDefault();
|
|
|
751
|
+ if (itemlast != null)
|
|
|
752
|
+ touser = itemlast.F_CreateUser;
|
|
|
753
|
+ var itemid = AddLog((int)model.F_ID, wostate, content, (int)EnumItemType.deal, optbut, touser, 0, nowUser, limit+time , sms);
|
|
|
754
|
+
|
|
|
755
|
+ #endregion
|
|
|
756
|
+
|
|
|
757
|
+ return true;
|
|
|
758
|
+ }
|
|
|
759
|
+
|
|
|
760
|
+
|
|
|
761
|
+
|
|
|
762
|
+ /// <summary>
|
|
|
763
|
+ /// 退回工单
|
|
|
764
|
+ /// </summary>
|
|
|
765
|
+ public bool BackWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont, int type)
|
|
|
766
|
+ {
|
|
|
767
|
+ #region 工单处理
|
|
|
768
|
+ int overtime = 0, sms = 0;
|
|
|
769
|
+ var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
|
|
|
770
|
+ if (itemlasts.Count > 0)
|
|
|
771
|
+ {
|
|
|
772
|
+ foreach (var it in itemlasts)
|
|
|
773
|
+ {
|
|
|
774
|
+ if (it.F_WoState == 1)
|
|
|
775
|
+ {
|
|
|
776
|
+ overtime = int.Parse(it.F_LimitTime);
|
|
|
777
|
+ sms = int.Parse(it.F_IsSMS.ToString());
|
|
|
778
|
+ }
|
|
|
779
|
+ }
|
|
|
780
|
+ }
|
|
|
781
|
+ var opt = "退回";
|
|
|
782
|
+ int optbut = (int)EnumItemOpt.reback;
|
|
|
783
|
+ int wostate = (int)EnumWorkOrderState.reback;
|
|
|
784
|
+ if (type == 1)
|
|
|
785
|
+ {
|
|
|
786
|
+ opt = "异常退回";
|
|
|
787
|
+ optbut = (int)EnumItemOpt.abreback;
|
|
|
788
|
+ wostate = (int)EnumWorkOrderState.abreback;
|
|
|
789
|
+ }
|
|
|
790
|
+ #region 读取当前登录人部门
|
|
|
791
|
+ string deptname = "";
|
|
|
792
|
+ var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
|
|
|
793
|
+ if (deptmodel != null)
|
|
|
794
|
+ {
|
|
|
795
|
+ deptname = deptmodel.F_DeptName + "-";
|
|
|
796
|
+ }
|
|
|
797
|
+ #endregion
|
|
|
798
|
+ var content = deptname + nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + opt + "工单,退回说明:" + cont;
|
|
|
799
|
+ //获取上一级处理人员
|
|
|
800
|
+ var touser = "";
|
|
|
801
|
+ var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_CreateTime desc").FirstOrDefault();
|
|
|
802
|
+ if (itemlast != null)
|
|
|
803
|
+ touser = itemlast.F_CreateUser;
|
|
|
804
|
+ var itemid = AddLog((int)model.F_ID , wostate, content, (int)EnumItemType.deal, optbut, touser, 0, nowUser, overtime,sms );
|
|
|
805
|
+ if (itemid > 0)
|
|
|
806
|
+ {
|
|
|
807
|
+ #region 处理工单
|
|
|
808
|
+ model.F_State = wostate;
|
|
|
809
|
+ workOrder .Update(model);
|
|
|
810
|
+ #endregion
|
|
|
811
|
+ #region 推送消息
|
|
|
812
|
+ #region 向上一级操作人员推送消息
|
|
|
813
|
+ if (!string.IsNullOrWhiteSpace(touser) && touser != nowUser.F_UserCode)
|
|
|
814
|
+ {//排除上一级指派人是自己
|
|
|
815
|
+ sendsysmsg(model, nowUser, touser, (int)itemid, opt);
|
|
|
816
|
+ // var lastUser = sysUserAccountBll.GetModel(touser);
|
|
|
817
|
+ // if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
|
|
|
818
|
+ // sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
|
|
|
819
|
+ }
|
|
|
820
|
+ #endregion
|
|
|
821
|
+ #endregion
|
|
|
822
|
+ return true;
|
|
|
823
|
+ }
|
|
|
824
|
+ else
|
|
|
825
|
+ return false;
|
|
|
826
|
+ #endregion
|
|
|
827
|
+ }
|
|
|
828
|
+ /// <summary>
|
|
|
829
|
+ /// 处理工单
|
|
|
830
|
+ /// </summary>
|
|
|
831
|
+ public bool DealWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont,int isover = 0,string uncont="")
|
|
|
832
|
+ {
|
|
|
833
|
+ #region 工单处理
|
|
|
834
|
+ int overtime = 0, sms = 0;
|
|
|
835
|
+ var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
|
|
|
836
|
+ if (itemlasts.Count > 0)
|
|
|
837
|
+ {
|
|
|
838
|
+ foreach (var it in itemlasts)
|
|
|
839
|
+ {
|
|
|
840
|
+ if (it.F_WoState == 1)
|
|
|
841
|
+ {
|
|
|
842
|
+ overtime = int.Parse(it.F_LimitTime);
|
|
|
843
|
+ sms = int.Parse(it.F_IsSMS.ToString());
|
|
|
844
|
+ }
|
|
|
845
|
+ }
|
|
|
846
|
+ }
|
|
|
847
|
+ var opt = "处理";
|
|
|
848
|
+ int optbut = (int)EnumItemOpt.deal;
|
|
|
849
|
+ int wostate = (int)EnumWorkOrderState.dealing;
|
|
|
850
|
+
|
|
|
851
|
+ if (isover == 1)
|
|
|
852
|
+ {
|
|
|
853
|
+ model.F_DealResult = "已处理";//处理结果
|
|
|
854
|
+ opt = "处理完结";
|
|
|
855
|
+ optbut = (int)EnumItemOpt.end;
|
|
|
856
|
+ wostate = (int)EnumWorkOrderState.finish;
|
|
|
857
|
+ model.F_DealBy = nowUser.F_UserCode;
|
|
|
858
|
+ model.F_DealTime = DateTime.Now;
|
|
|
859
|
+ }
|
|
|
860
|
+ else
|
|
|
861
|
+ {
|
|
|
862
|
+ model.F_DealResult = "未处理";//处理结果
|
|
|
863
|
+ model.F_DealReasons = uncont;//未处理原因
|
|
|
864
|
+ }
|
|
|
865
|
+ #region 读取当前登录人部门
|
|
|
866
|
+ string deptname = "";
|
|
|
867
|
+ var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
|
|
|
868
|
+ if (deptmodel != null)
|
|
|
869
|
+ {
|
|
|
870
|
+ deptname = deptmodel.F_DeptName + "-";
|
|
|
871
|
+ }
|
|
|
872
|
+ #endregion
|
|
|
873
|
+ var optcont = "";
|
|
|
874
|
+ if (!string.IsNullOrEmpty(cont))
|
|
|
875
|
+ optcont = ",处理内容:" + cont;
|
|
|
876
|
+ var content = deptname + nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + opt + "工单" + optcont;
|
|
|
877
|
+ var itemid = AddLog(model.F_ID , wostate, content, (int)EnumItemType.deal, optbut, "", 0, nowUser, overtime,sms );
|
|
|
878
|
+ if (itemid > 0)
|
|
|
879
|
+ {
|
|
|
880
|
+ #region 处理工单
|
|
|
881
|
+ model.F_State = wostate;
|
|
|
882
|
+ //处理内容
|
|
|
883
|
+ if (!string.IsNullOrEmpty(cont))
|
|
|
884
|
+ model.F_DealContent += cont + ";";
|
|
|
885
|
+
|
|
|
886
|
+ workOrder.Update(model);
|
|
|
887
|
+ #endregion
|
|
|
888
|
+ #region 推送消息
|
|
|
889
|
+ #region 推送消息给添加的坐席 -处理情况
|
|
|
890
|
+ if (nowUser.F_UserCode != model.F_CreateBy)
|
|
|
891
|
+ {
|
|
|
892
|
+ sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID , opt);//推送系统消息
|
|
|
893
|
+ var createmodel = sysUserAccountBll.GetModel(model.F_CreateBy); //被指派人
|
|
|
894
|
+ if (createmodel != null)
|
|
|
895
|
+ {
|
|
|
896
|
+ // if (!string.IsNullOrEmpty(createmodel.F_WxOpenId))
|
|
|
897
|
+ // {
|
|
|
898
|
+ // sendwxmsg(model, createmodel.F_WxOpenId, nowUser, opt);
|
|
|
899
|
+ // }
|
|
|
900
|
+ }
|
|
|
901
|
+ }
|
|
|
902
|
+ #endregion
|
|
|
903
|
+ #region 向上一级操作人员推送消息
|
|
|
904
|
+ var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_CreateTime desc").FirstOrDefault();
|
|
|
905
|
+ if (itemlast.F_CreateUser != model.F_CreateBy)
|
|
|
906
|
+ {
|
|
|
907
|
+ sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, opt);
|
|
|
908
|
+ var lastUser = sysUserAccountBll.GetModel(itemlast.F_CreateUser);
|
|
|
909
|
+ // if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
|
|
|
910
|
+ // sendwxmsg(model, lastUser.F_WxOpenId, nowUser, opt);
|
|
|
911
|
+ }
|
|
|
912
|
+ #endregion
|
|
|
913
|
+ #region 办理完结向客户发送消息
|
|
|
914
|
+ //if (model.F_State == (int)EnumWorkOrderState.finish)
|
|
|
915
|
+ //{
|
|
|
916
|
+ // if (model.CustomerID != null)
|
|
|
917
|
+ // {
|
|
|
918
|
+ // var cusmodel = cusBll.GetModel(model.CustomerID.Value);
|
|
|
919
|
+ // if (cusmodel != null && !string.IsNullOrEmpty(cusmodel.F_WxOpenId))
|
|
|
920
|
+ // {
|
|
|
921
|
+ // sendwxmsg(model, cusmodel.F_WxOpenId, nowUser, opt);
|
|
|
922
|
+ // }
|
|
|
923
|
+ // }
|
|
|
924
|
+ //}
|
|
|
925
|
+ #endregion
|
|
|
926
|
+ #endregion
|
|
|
927
|
+ return true;
|
|
|
928
|
+ }
|
|
|
929
|
+ else
|
|
|
930
|
+ return false;
|
|
|
931
|
+ #endregion
|
|
|
932
|
+ }
|
|
|
933
|
+ /// <summary>
|
|
|
934
|
+ /// 接单
|
|
|
935
|
+ /// </summary>
|
|
|
936
|
+ public bool SureWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model)
|
|
389
|
937
|
{
|
|
|
938
|
+ int overtime=0, sms=0;
|
|
|
939
|
+ var itemlasts = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID=" + model.F_ID + " ");
|
|
|
940
|
+ if (itemlasts.Count > 0)
|
|
|
941
|
+ {
|
|
|
942
|
+ foreach (var it in itemlasts)
|
|
|
943
|
+ {
|
|
|
944
|
+ if (it .F_WoState ==1)
|
|
|
945
|
+ {
|
|
|
946
|
+ overtime =int .Parse ( it.F_LimitTime);
|
|
|
947
|
+ sms = int.Parse(it.F_IsSMS.ToString ());
|
|
|
948
|
+ }
|
|
|
949
|
+ }
|
|
|
950
|
+ }
|
|
|
951
|
+ #region 工单处理
|
|
|
952
|
+ var opt = "处理接单";
|
|
|
953
|
+ int optbut = (int)EnumItemOpt.receive;
|
|
|
954
|
+ int wostate = (int)EnumWorkOrderState.receive;
|
|
390
|
955
|
|
|
391
|
|
- return View();
|
|
|
956
|
+ #region 读取当前登录人部门
|
|
|
957
|
+ string deptname = "";
|
|
|
958
|
+ var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
|
|
|
959
|
+ if (deptmodel != null)
|
|
|
960
|
+ {
|
|
|
961
|
+ deptname = deptmodel.F_DeptName + "-";
|
|
|
962
|
+ }
|
|
|
963
|
+ #endregion
|
|
|
964
|
+ var content = deptname + nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + opt;
|
|
|
965
|
+ var itemid = AddLog((int)model.F_ID , wostate, content, (int)EnumItemType.deal, optbut, "", 0, nowUser, overtime,sms );
|
|
|
966
|
+ if (itemid > 0)
|
|
|
967
|
+ {
|
|
|
968
|
+ #region 处理工单
|
|
|
969
|
+ model.F_State = wostate;//已接单待处理
|
|
|
970
|
+ workOrder.Update(model);
|
|
|
971
|
+ #endregion
|
|
|
972
|
+ #region 推送消息
|
|
|
973
|
+ //读取上一级指派人员以及添加坐席并推送系统消息和微信消息
|
|
|
974
|
+ #region 给添加坐席推送系统消息和微信消息
|
|
|
975
|
+ sendsysmsg(model, nowUser, model.F_CreateBy , (int)itemid, "处理接单");
|
|
|
976
|
+ var createUser = sysUserAccountBll.GetModel(model.F_CreateBy);
|
|
|
977
|
+ // if (createUser != null && !string.IsNullOrEmpty(createUser.F_WxOpenId))
|
|
|
978
|
+ // sendwxmsg(model, createUser.F_WxOpenId, nowUser, "接单");
|
|
|
979
|
+ #endregion
|
|
|
980
|
+ #region 读取上一级指派人员推送系统消息和微信消息
|
|
|
981
|
+ var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and F_WoID='" + model.F_ID + "' and F_NextUser='" + nowUser.F_UserCode + "' order by F_CreateTime desc").FirstOrDefault();
|
|
|
982
|
+ if (itemlast.F_CreateUser != model.F_CreateBy)
|
|
|
983
|
+ {
|
|
|
984
|
+ sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, "处理接单");
|
|
|
985
|
+ var lastUser = sysUserAccountBll.GetModel(itemlast.F_CreateUser);
|
|
|
986
|
+ // if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
|
|
|
987
|
+ // sendwxmsg(model, lastUser.F_WxOpenId, nowUser, "接单");
|
|
|
988
|
+ }
|
|
|
989
|
+ #endregion
|
|
|
990
|
+ #endregion
|
|
|
991
|
+ return true;
|
|
|
992
|
+ }
|
|
|
993
|
+ else
|
|
|
994
|
+ return false;
|
|
|
995
|
+ #endregion
|
|
|
996
|
+ }
|
|
|
997
|
+
|
|
|
998
|
+ /// <summary>
|
|
|
999
|
+ /// 转派工单
|
|
|
1000
|
+ /// </summary>
|
|
|
1001
|
+ public bool AssignWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, string cont, int clbm = 0, int clid = 0,int overtime = 0, int sms = 0)
|
|
|
1002
|
+ {
|
|
|
1003
|
+ string touser = ""; string tousername = "";
|
|
|
1004
|
+ #region 获取接收人
|
|
|
1005
|
+ if (clid != 0)
|
|
|
1006
|
+ {
|
|
|
1007
|
+ Model.T_Sys_UserAccount clus = sysUserAccountBll.GetModel(clid);
|
|
|
1008
|
+ if (clus != null)
|
|
|
1009
|
+ {
|
|
|
1010
|
+ touser = clus.F_UserCode;
|
|
|
1011
|
+ tousername = clus.F_UserName + "(" + touser + ")";
|
|
|
1012
|
+ }
|
|
|
1013
|
+ }
|
|
|
1014
|
+ else
|
|
|
1015
|
+ {
|
|
|
1016
|
+ string users = string.Empty;
|
|
|
1017
|
+ var list = sysUserAccountBll.GetModelList(" F_DeptId='" + clbm + "'");
|
|
|
1018
|
+ foreach (var l in list)
|
|
|
1019
|
+ {
|
|
|
1020
|
+ if (string.IsNullOrEmpty(users))
|
|
|
1021
|
+ {
|
|
|
1022
|
+ users = l.F_UserCode;
|
|
|
1023
|
+ tousername = l.F_UserName + "(" + l.F_UserCode + ")";
|
|
|
1024
|
+ }
|
|
|
1025
|
+ else
|
|
|
1026
|
+ {
|
|
|
1027
|
+ users = users + "," + l.F_UserCode;
|
|
|
1028
|
+ tousername = tousername + "," + l.F_UserName + "(" + l.F_UserCode + ")";
|
|
|
1029
|
+ }
|
|
|
1030
|
+ }
|
|
|
1031
|
+ touser = users;
|
|
|
1032
|
+ }
|
|
|
1033
|
+ #endregion
|
|
|
1034
|
+ #region 工单处理
|
|
|
1035
|
+ var opt = "指派";
|
|
|
1036
|
+ int optbut = (int)EnumItemOpt.assign;
|
|
|
1037
|
+ int wostate = (int)EnumWorkOrderState.assign;//已指派待接单
|
|
|
1038
|
+ #region 读取当前登录人部门
|
|
|
1039
|
+ string deptname = "";
|
|
|
1040
|
+ var deptmodel = departmentBLL.GetModel(nowUser.F_DeptId);
|
|
|
1041
|
+ if (deptmodel != null)
|
|
|
1042
|
+ {
|
|
|
1043
|
+ deptname = deptmodel.F_DeptName + "-";
|
|
|
1044
|
+ }
|
|
|
1045
|
+ #endregion
|
|
|
1046
|
+ var optcont = "";
|
|
|
1047
|
+ if (!string.IsNullOrEmpty(cont))
|
|
|
1048
|
+ optcont = ",说明:" + cont;
|
|
|
1049
|
+ var content = deptname + nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + opt + "工单给 " + tousername + optcont;
|
|
|
1050
|
+ var itemid = AddLog(model.F_ID , wostate, content, (int)EnumItemType.deal, optbut, touser, clbm, nowUser , overtime,sms);
|
|
|
1051
|
+ if (itemid > 0)
|
|
|
1052
|
+ {
|
|
|
1053
|
+ #region 处理工单
|
|
|
1054
|
+ //工单完结要更新工单的状态
|
|
|
1055
|
+ model.F_DealBy = touser;
|
|
|
1056
|
+ model.F_State = wostate;
|
|
|
1057
|
+ //处理内容
|
|
|
1058
|
+ if (!string.IsNullOrEmpty(cont))
|
|
|
1059
|
+ model.F_DealContent += cont + ";";
|
|
|
1060
|
+ workOrder.Update(model);
|
|
|
1061
|
+ #endregion
|
|
|
1062
|
+ #region 推送消息
|
|
|
1063
|
+ #region 推送消息给添加的坐席 -转派和处理
|
|
|
1064
|
+ if (nowUser.F_UserCode != model.F_CreateBy)
|
|
|
1065
|
+ {
|
|
|
1066
|
+ sendsysmsg(model, nowUser, model.F_CreateBy, (int)model.F_ID , opt);//推送系统消息
|
|
|
1067
|
+ }
|
|
|
1068
|
+ #endregion
|
|
|
1069
|
+ #region 向下一级操作人员推送消息
|
|
|
1070
|
+ if (!string.IsNullOrWhiteSpace(touser))
|
|
|
1071
|
+ {
|
|
|
1072
|
+ sendsysmsg(model, nowUser, touser, (int)model.F_ID , opt);//推送系统消息
|
|
|
1073
|
+ }
|
|
|
1074
|
+ #endregion
|
|
|
1075
|
+ #endregion
|
|
|
1076
|
+ return true;
|
|
|
1077
|
+ }
|
|
|
1078
|
+ else
|
|
|
1079
|
+ return false;
|
|
|
1080
|
+ #endregion
|
|
|
1081
|
+ }
|
|
|
1082
|
+ //推送系统提醒
|
|
|
1083
|
+ public void sendsysmsg(Model.T_Wo_WorkOrder womodel, Model.T_Sys_UserAccount nowUser, string touser, int toid, string opt)
|
|
|
1084
|
+ {
|
|
|
1085
|
+ #region 消息提醒
|
|
|
1086
|
+ string strmsg = string.Empty;
|
|
|
1087
|
+ strmsg = nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + "操作" + opt + "工单";
|
|
|
1088
|
+ Model.T_Msg_List msg = new Model.T_Msg_List();
|
|
|
1089
|
+ msg.Type = (int)Model.MSGType.workorder;//处理
|
|
|
1090
|
+ msg.ToUser = touser;
|
|
|
1091
|
+ msg.ToID = toid;
|
|
|
1092
|
+ msg.Detail = strmsg;
|
|
|
1093
|
+ msg.State = 0;
|
|
|
1094
|
+ msg.IsDel = 0;
|
|
|
1095
|
+ msg.CreateUser = nowUser.F_UserCode;
|
|
|
1096
|
+ msg.CreateDate = DateTime.Now;
|
|
|
1097
|
+
|
|
|
1098
|
+ new BLL.T_Msg_List().Add(msg);
|
|
|
1099
|
+ #endregion
|
|
392
|
1100
|
}
|
|
393
|
1101
|
}
|
|
394
|
1102
|
}
|