Browse Source

工单修改

duhongyu 6 years ago
parent
commit
471bbf8374

+ 364 - 100
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderNewController.cs

@@ -22,6 +22,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
22 22
         BLL.T_Wo_WorkOrderItem_New itembll = new BLL.T_Wo_WorkOrderItem_New();
23 23
         BLL.T_Wo_WorkOrder_Logs blllogs = new BLL.T_Wo_WorkOrder_Logs();
24 24
         BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
25
+        BLL.T_Sys_RoleInfo rolebll = new BLL.T_Sys_RoleInfo();
26
+        
25 27
         // GET: WorkOrderNew
26 28
         /// <summary>
27 29
         /// 获取工单列表
@@ -30,64 +32,169 @@ namespace CallCenterApi.Interface.Controllers.workorder
30 32
         public ActionResult GetList(string code, string cusname, string cusphone, string companyname, string province, string city,
31 33
             string country, string township, string touser, int type = 0, int state=-1, int pageindex = 1,int pagesize = 10)
32 34
         {
35
+           
36
+              int userId = CurrentUser.UserData.F_UserId;
37
+            if (userId != 0)
38
+            {
39
+                string sql = $" and F_IsDelete=0";
40
+                DataTable dt = new DataTable();
41
+                #region 筛选条件
42
+                if (type > 0 && type < 4)//工单类型
43
+                    sql += $" and F_Type=" + type;
44
+                if (state > 0)//工单状态
45
+                    sql += $" and F_State=" + state;
46
+                if (!string.IsNullOrWhiteSpace(touser))//参与人
47
+                    sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
48
+                if (!string.IsNullOrWhiteSpace(code))//工单编号
49
+                    sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
50
+                if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
51
+                    sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
52
+                if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
53
+                    sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
54
+                if (!string.IsNullOrWhiteSpace(companyname))//公司名称
55
+                    sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
56
+                if (!string.IsNullOrWhiteSpace(province))//省
57
+                    sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
58
+                if (!string.IsNullOrWhiteSpace(province))//市
59
+                    sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
60
+                if (!string.IsNullOrWhiteSpace(province))//县
61
+                    sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
62
+                if (!string.IsNullOrWhiteSpace(province))//乡
63
+                    sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
64
+                #endregion
65
+                int recordCount = 0;
66
+                if (!string.IsNullOrWhiteSpace(sql))
67
+                {
33 68
 
34
-            string sql = $" and F_IsDelete=0";
35
-            DataTable dt = new DataTable();
36
-            #region 筛选条件
37
-            if (type > 0&& type <4)//工单类型
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() + "%'";
43
-            if (!string.IsNullOrWhiteSpace(code))//工单编号
44
-                sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
45
-            if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
46
-                sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
47
-            if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
48
-                sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
49
-            if (!string.IsNullOrWhiteSpace(companyname))//公司名称
50
-                sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
51
-            if (!string.IsNullOrWhiteSpace(province))//省
52
-                sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
53
-            if (!string.IsNullOrWhiteSpace(province))//市
54
-                sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
55
-            if (!string.IsNullOrWhiteSpace(province))//县
56
-                sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
57
-            if (!string.IsNullOrWhiteSpace(province))//乡
58
-                sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
59
-            #endregion
60
-            int recordCount = 0;
61
-            if (!string.IsNullOrWhiteSpace(sql))
69
+                    dt = BLL.PagerBLL.GetListPager(
70
+                        "T_Wo_WorkOrder",
71
+                        "F_ID",
72
+                        "*,dbo.GetUserName(F_CreateBy) as F_CreateByName",
73
+                        sql,
74
+                        "ORDER BY F_CustomerId desc",
75
+                        pagesize,
76
+                        pageindex,
77
+                        true,
78
+                        out recordCount);
79
+                }
80
+                int total = 0;
81
+                List<long> woid = new List<long>();
82
+                List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
83
+                List<Model.T_Wo_WorkOrder> list = new List<Model.T_Wo_WorkOrder>();
84
+                Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
85
+                if (ua.F_RoleId == 1 || ua.F_RoleId == 58 || ua.F_RoleId == 59)
86
+                {
87
+                    if (modlelist.Count >0)
88
+                    {
89
+                        foreach (var it in modlelist)
90
+                        {
91
+                            if (it.F_DealBy == ua.F_UserCode)
92
+                            {
93
+                                list.Add(it);
94
+                                total++;
95
+                            }
96
+                        }
97
+                    }
98
+                  
99
+                }
100
+               else  if (ua.F_RoleId == 60 || ua.F_RoleId == 61 || ua.F_RoleId == 63)
101
+                {
102
+                    List<int> detpid = new List<int>();
103
+                    var deparmentlist = new List<Model.T_Sys_Department>();
104
+                    Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
105
+                    if (dModel != null)
106
+                    {
107
+
108
+                        if (dModel.F_Layer == 1)
109
+                        {
110
+                            deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
111
+                            if (deparmentlist.Count > 0)
112
+                            {
113
+                                foreach (var it in deparmentlist)
114
+                                {
115
+                                    detpid.Add(it.F_DeptId);
116
+                                  
117
+                                }
118
+                            }
119
+                        }
120
+                        detpid.Add(dModel.F_DeptId);
121
+                        var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' " + " ");
122
+                        if (itemlast.Count > 0)
123
+                        {
124
+                            foreach (var it in itemlast)
125
+                            {
126
+                                for (int i = 0; i < detpid.Count; i++)
127
+                                {
128
+                                    if (it.F_NextDept == detpid[i])
129
+                                    {
130
+                                        woid.Add(it.F_WoID);
131
+                                    }
132
+                                }
133
+                            }
134
+                        }
135
+                        if (modlelist.Count >0 && woid.Count > 0)
136
+                        {
137
+                            foreach (var it in modlelist)
138
+                            {
139
+                                for (int i = 0; i < woid.Count; i++)
140
+                                {
141
+                                    if (it.F_ID == woid[i])
142
+                                    {
143
+                                        list.Add(it);
144
+                                        total++;
145
+                                    }
146
+                                }
147
+                            }
148
+                        }
149
+                       
150
+                    }
151
+                    else
152
+                    {
153
+                        return Error("加载失败");
154
+                    }
155
+                }
156
+                else
157
+                {
158
+                    if (modlelist.Count > 0 )
159
+                    {
160
+                        foreach (var it in modlelist)
161
+                        {
162
+                           list.Add(it);
163
+                            total++;
164
+                        }
165
+                    }
166
+                }
167
+                if (list.Count >0)
168
+                {
169
+                    List<WorkOrderNewInput> Input = modeltooip(list);
170
+                    var obj = new
171
+                    {
172
+                        state = "success",
173
+                        message = "成功",
174
+                        rows = Input,
175
+                        total = total
176
+                    };
177
+
178
+                    return Content(obj.ToJson()); ;
179
+                }
180
+                else
181
+                {
182
+
183
+                    return Success ("暂无工单"); ;
184
+                }
185
+               
186
+
187
+            }
188
+            else
62 189
             {
63
-                dt = BLL.PagerBLL.GetListPager(
64
-                    "T_Wo_WorkOrder",
65
-                    "F_ID",
66
-                    "*,dbo.GetUserName(F_CreateBy) as F_CreateByName",
67
-                    sql,
68
-                    "ORDER BY F_CustomerId desc",
69
-                    pagesize,
70
-                    pageindex,
71
-                    true,
72
-                    out recordCount);
190
+                return Error("无操作权限!");
73 191
             }
74 192
            
75
-            List<Model.T_Wo_WorkOrder> modlelist = new BLL.T_Wo_WorkOrder().DataTableToList(dt);
76
-            List<WorkOrderNewInput> Input = modeltooip(modlelist);
77
-            var obj = new
78
-            {
79
-                state = "success",
80
-                message = "成功",
81
-                rows = Input,
82
-                total = recordCount
83
-            };
84
-
85
-            return Content(obj.ToJson()); ;
86 193
         }
87
-        /// <summary>
88
-        /// 查询工单详情
89
-        /// </summary>
90
-        public ActionResult GetDetails(int id)
194
+            /// <summary>
195
+            /// 查询工单详情
196
+            /// </summary>
197
+            public ActionResult GetDetails(int id)
91 198
         {
92 199
             int userId = CurrentUser.UserData.F_UserId;
93 200
             if (userId != 0)
@@ -138,30 +245,158 @@ namespace CallCenterApi.Interface.Controllers.workorder
138 245
             }
139 246
         }
140 247
         /// <summary>
248
+        /// 查询参与工单列表
249
+        /// </summary>
250
+        public ActionResult GetParticipate()
251
+        {
252
+            int userId = CurrentUser.UserData.F_UserId;
253
+            if (userId != 0)
254
+            {
255
+                Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
256
+                string sql = "";
257
+                if (ua!=null )
258
+                {
259
+                    sql += $" ( F_DealBy like '%" + ua.F_UserCode  + "%' ) ";
260
+                }
261
+                else
262
+                    return Error("请输入正确的id");
263
+                var list = new List<Model.T_Wo_WorkOrder>();
264
+                if (!string.IsNullOrWhiteSpace(sql))
265
+                {
266
+                    sql += " and F_IsDelete=0";
267
+                    list = workOrder.GetModelList(sql);
268
+                }
269
+              
270
+
271
+                if (list.Count > 0)
272
+                {
273
+                    List<WorkOrderNewInput> Input = modeltooip(list);
274
+                    if (Input != null)
275
+                    {
276
+                        var obj = new
277
+                        {
278
+                            state = "success",
279
+                            message = "成功",
280
+                            rows = Input,
281
+                        };
282
+
283
+                        return Content(obj.ToJson());
284
+                    }
285
+                    else
286
+                    {
287
+                        return Error("暂无参与工单");
288
+                    }
289
+                }
290
+                else
291
+                    return Error("暂无参与工单");
292
+
293
+            }
294
+            else
295
+            {
296
+                return Error("无操作权限!");
297
+            }
298
+        }
299
+        /// <summary>
300
+        /// 查询个人超时工单列表
301
+        /// </summary>
302
+        public ActionResult GetOvertime()
303
+        {
304
+            int userId = CurrentUser.UserData.F_UserId;
305
+            if (userId != 0)
306
+            {
307
+                Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
308
+              //  Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua .F_RoleId);
309
+                string sql = "";
310
+                if (ua != null)
311
+                {
312
+                    sql += $" ( F_DealBy like '%" + ua.F_UserCode + "%' ) ";
313
+                }
314
+                else
315
+                    return Error("请输入正确的id");
316
+                var list = new List<Model.T_Wo_WorkOrder>();
317
+                if (!string.IsNullOrWhiteSpace(sql))
318
+                {
319
+                    sql += " and F_IsDelete=0";
320
+                    list = workOrder.GetModelList(sql);
321
+                }
322
+
323
+
324
+                if (list.Count > 0)
325
+                {
326
+                    List<WorkOrderNewInput> Input = modeltooip(list);
327
+                    List<WorkOrderNewInput> model = new List<WorkOrderNewInput> ();
328
+                    if (Input != null)
329
+                    {
330
+                        foreach(var  it in Input)
331
+                        {
332
+                            if (it .F_IsOver==1)
333
+                            {
334
+                                model.Add(it);
335
+                            }
336
+                        }
337
+                        var obj = new
338
+                        {
339
+                            state = "success",
340
+                            message = "成功",
341
+                            rows = model,
342
+                        };
343
+
344
+                        return Content(obj.ToJson());
345
+                    }
346
+                    else
347
+                    {
348
+                        return Error("暂无超时工单");
349
+                    }
350
+                }
351
+                else
352
+                    return Error("暂无超时工单");
353
+
354
+            }
355
+            else
356
+            {
357
+                return Error("无操作权限!");
358
+            }
359
+        }
360
+        /// <summary>
141 361
         /// 添加工单
142 362
         /// </summary>
143 363
         /// <returns></returns>
144 364
         public ActionResult Add(WorkOrderNewInput input)
145 365
         {
146
-            string usercode = CurrentUser.UserData.F_UserCode;
147
-            #region 添加验证判断
148
-            if (!(input.F_Type>0 && input.F_Type<4))
149
-                return Error("工单类型错误!");
150
-            #endregion
151
-            var model = new Model.T_Wo_WorkOrder();
152
-            #region 保存客户基本信息
153
-            model = inputtoobj(model, input);
154
-            model.F_CreateBy = usercode;
155
-            model.F_CreateOn = DateTime.Now;
156
-            model.F_IsDelete = 0;
157
-            #endregion
158
-            long n = workOrder.Add(model);
159
-            if (n > 0)
366
+            int userId = CurrentUser.UserData.F_UserId;
367
+            if (userId != 0)
160 368
             {
161
-                return Success("添加成功!");
369
+                string usercode = CurrentUser.UserData.F_UserCode;
370
+                Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
371
+
372
+                #region 添加验证判断
373
+                if (!(input.F_Type > 0 && input.F_Type < 4))
374
+                    return Error("工单类型错误!");
375
+                #endregion
376
+                var model = new Model.T_Wo_WorkOrder();
377
+                #region 保存客户基本信息
378
+                model = inputtoobj(model, input, 2);
379
+
380
+                #endregion
381
+                long n = workOrder.Add(model);
382
+                if (n > 0)
383
+                {
384
+                    string deptname = "";
385
+                    var deptmodel = departmentBLL.GetModel(ua.F_DeptId);
386
+                    if (deptmodel != null)
387
+                    {
388
+                        deptname = deptmodel.F_DeptName + "-";
389
+                    }
390
+                    return Success("添加成功!");
391
+
392
+                }
393
+                else
394
+                    return Error("添加失败!");
162 395
             }
163 396
             else
164
-                return Error("添加失败!");
397
+            {
398
+                return Error("无操作权限!");
399
+            }
165 400
         }
166 401
         /// <summary>
167 402
         /// 删除工单
@@ -243,7 +478,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
243 478
                 #endregion
244 479
                 var model = workOrder.GetModel(input.F_ID);
245 480
                 #region 保存客户基本信息
246
-                model = inputtoobj(model, input);
481
+                model = inputtoobj(model, input,1);
247 482
                 #endregion
248 483
                 bool n = workOrder.Update(model);
249 484
                 if (n)
@@ -377,14 +612,15 @@ namespace CallCenterApi.Interface.Controllers.workorder
377 612
                      model.F_DealResult = model1[i].F_DealResult;//处理结果
378 613
                     model.F_DealReasons = model1[i].F_DealReasons;//未处理原因
379 614
                     model.F_CreateBy = model1[i].F_CreateBy;//添加人工号
380
-                    if (TimeforOver(model1[i].F_ID ))
615
+                    if (TimeforOver(model1[i].F_ID))
381 616
                     {
382
-                        model.F_IsOver = 0;
617
+                        model1[i].F_IsOver = 0;
383 618
                     }
384
-                   else
619
+                    else
385 620
                     {
386
-                        model.F_IsOver = 1;
621
+                        model1[i].F_IsOver = 1;
387 622
                     }
623
+                    model.F_IsOver = model1[i].F_IsOver;
388 624
                     #endregion
389 625
                     Input.Add(model);
390 626
                  
@@ -406,45 +642,58 @@ namespace CallCenterApi.Interface.Controllers.workorder
406 642
         private bool  TimeforOver(int id)
407 643
         {
408 644
             var itemlasts = itembll.GetModelList("  F_ItemType=" + (int)EnumItemType.deal + " and  F_WoID=" + id + " ");
409
-            string  time1="", time2="" ;
645
+            string  time1="", time2="" ;int x=0, y=0;
410 646
             int time = 0;
411 647
             if (itemlasts.Count > 0)
412 648
             {
413
-                foreach (var it in itemlasts)
649
+                for (int i=0;i < itemlasts.Count;i++)
414 650
                 {
415
-                    if (it.F_WoState >= 2)
651
+                    if (itemlasts[i ].F_WoState >= 2)
416 652
                     {
417
-                        if (it.F_WoState == 2)
653
+                        if (itemlasts[i].F_WoState == 2)
418 654
                         {
419
-                            time1 = it.F_CreateTime.ToString();
420
-                            time =int .Parse ( it.F_LimitTime);
655
+                            x = i;
656
+                            time1 = itemlasts[i].F_CreateTime.ToString();
657
+                            time = int.Parse(itemlasts[i].F_LimitTime);
421 658
                         }
422
-                        if (it.F_WoState==10)
659
+                        if (itemlasts[i].F_WoState == 10)
423 660
                         {
424
-                            time2 = it.F_CreateTime.ToString();
661
+                            y = i;
662
+                            time2 = itemlasts[i].F_CreateTime.ToString();
425 663
                         }
426
-                        if (time2!="")
664
+                    }
665
+                }
666
+                if (time2 != "")
667
+                {
668
+                    if (x > y)
669
+                    {
670
+                        int a = (DateTime.Parse(time2) - DateTime.Parse(time1)).Hours;
671
+                        if (a > time)
427 672
                         {
428
-                            int a= (DateTime.Parse(time2) - DateTime.Parse(time1)).Hours ;
429
-                            if (a > time)
430
-                            {
431
-                                return false;
432
-                            }
673
+                            return false;
433 674
                         }
434
-                        else
675
+                    }
676
+                    else
677
+                    {
678
+                        int a = (DateTime.Now - DateTime.Parse(time1)).Hours;
679
+                        if (a > time)
435 680
                         {
436
-                            int a = (DateTime.Now  - DateTime.Parse(time1)).Hours;
437
-                            if (a > time)
438
-                            {
439
-                                return false;
440
-                            }
681
+                            return false;
441 682
                         }
442 683
                     }
443
-                    else
684
+                }
685
+                else if (time1 != "")
686
+                {
687
+                    int a = (DateTime.Now - DateTime.Parse(time1)).Hours;
688
+                    if (a > time)
444 689
                     {
445
-                        return true ;
690
+                        return false;
446 691
                     }
447 692
                 }
693
+                else
694
+                {
695
+                    return true;
696
+                }
448 697
             }
449 698
             else
450 699
             {
@@ -455,8 +704,9 @@ namespace CallCenterApi.Interface.Controllers.workorder
455 704
         /// <summary>
456 705
         /// 根据传入的对象和input的内容返回对象(添加修改使用)
457 706
         /// </summary>
458
-        private Model.T_Wo_WorkOrder inputtoobj(Model.T_Wo_WorkOrder model, WorkOrderNewInput input)
707
+        private Model.T_Wo_WorkOrder inputtoobj(Model.T_Wo_WorkOrder model, WorkOrderNewInput input,int type)
459 708
         {
709
+            string usercode = CurrentUser.UserData.F_UserCode;
460 710
             var newmodel = model;
461 711
             if (input.F_ID!=0)
462 712
                 model.F_ID = input.F_ID;
@@ -506,15 +756,29 @@ namespace CallCenterApi.Interface.Controllers.workorder
506 756
             model.F_CJ_Tonnage = input.F_CJ_Tonnage;//抽检-抽检吨数
507 757
             model.F_CJ_BagNo = input.F_CJ_BagNo;//抽检-抽检袋数
508 758
             model.F_CJ_Outlay = input.F_CJ_Outlay;//抽检-公关费用金额:单位元】
509
-            if (input.F_State != null )
759
+            if (type ==1)
510 760
             {
511
-                model.F_State = input.F_State;//抽检-公关费用金额:单位元】
761
+                model.F_State = input.F_State;//工单状态
762
+                model.F_CreateOn = input.F_CreateOn;//添加时间
763
+                model.F_CreateBy = input.F_CreateBy;//添加人
764
+                model.F_UpdateBy = usercode;//修改人工号
765
+                model.F_UpdateOn = DateTime .Now ;//修改人工号
766
+                if (input.F_UpdateCount!=null )
767
+                {
768
+                    model.F_UpdateCount = input.F_UpdateCount + 1;//修改次数
769
+                }
770
+                else
771
+                {
772
+                    model.F_UpdateCount = 1;//修改次数
773
+                }
512 774
             }
513 775
             else
514 776
             {
515 777
                 model.F_State = (int)EnumWorkOrderState.neworder;
778
+                model.F_CreateBy = usercode;
779
+                model.F_CreateOn = DateTime.Now;
516 780
             }
517
-          
781
+            model.F_IsDelete = 0;
518 782
             #endregion
519 783
             return model;
520 784
         }