Browse Source

工单bug修改

duhongyu 6 years ago
parent
commit
5a018d2952

+ 363 - 248
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderNewController.cs

@@ -30,7 +30,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
30 30
         /// </summary>
31 31
         /// <returns></returns>
32 32
         public ActionResult GetList(string code, string cusname, string cusphone, string companyname, string province, string city,
33
-            string country, string township, string touser, int type = 0, int state=-1, int pageindex = 1,int pagesize = 10)
33
+            string country, string township, string touser, int source=0,int type = 0, int state=0, int pageindex = 1,int pagesize = 10)
34 34
         {
35 35
            
36 36
               int userId = CurrentUser.UserData.F_UserId;
@@ -41,8 +41,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
41 41
                 #region 筛选条件
42 42
                 if (type > 0 && type < 4)//工单类型
43 43
                     sql += $" and F_Type=" + type;
44
-                if (state >=0)//工单状态
45
-                    sql += $" and F_State=" + state;
44
+                if (source > 0)//工单来源
45
+                    sql += $" and F_Source=" + source;
46 46
                 if (!string.IsNullOrWhiteSpace(touser))//参与人
47 47
                     sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
48 48
                 if (!string.IsNullOrWhiteSpace(code))//工单编号
@@ -61,6 +61,44 @@ namespace CallCenterApi.Interface.Controllers.workorder
61 61
                     sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
62 62
                 if (!string.IsNullOrWhiteSpace(province))//乡
63 63
                     sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
64
+                Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
65
+                Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
66
+                string uwhere = " ";
67
+                switch (state)
68
+                {
69
+                    case 0://待指派的
70
+                        if (ro.F_RoleCode == "YWY" ||  ro.F_RoleCode == "JDYPTZX" )
71
+                        {
72
+                            sql += $" and F_DealBy like '%" + ua.F_UserCode + "%'";
73
+                        }
74
+                        else
75
+                        {
76
+                            uwhere = "";
77
+                        }
78
+                        sql += $" and F_State=" + (int)EnumWorkOrderState.neworder + " " + uwhere;
79
+                        break;
80
+                    case 1://待接单的
81
+                      if (GetDJDWorkOrderID(ua.F_UserCode)!="")
82
+                        {
83
+                            sql += $" and F_State=" + (int)EnumWorkOrderState.assign + $"  and T_Wo_WorkOrder.F_ID in ( " + GetDJDWorkOrderID(ua.F_UserCode) + ") ";;
84
+                        }
85
+                        else
86
+                        {
87
+
88
+                            return Success("暂无工单"); ;
89
+                        }
90
+
91
+                        break;
92
+                    case 2://待完成的(待处理)
93
+                        sql += " and F_State in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + "," + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ") and T_Wo_WorkOrder.F_ID in ( " + GetDWCWorkOrderID(ua.F_UserCode) + ") ";
94
+                        break;
95
+                    case 10://已完成的
96
+                        sql += " and F_State =" + (int)EnumWorkOrderState.finish + " and F_DealBy = '" + ua.F_UserCode + "' ";
97
+                        break;
98
+                    case 3://我参与的
99
+                        sql += " and (F_CreateBy= '" + ua.F_UserCode + "' or T_Wo_WorkOrder.F_ID in ( " + GetCYWorkOrderID(ua.F_UserCode) + ")) ";
100
+                        break;
101
+                }
64 102
                 #endregion
65 103
                 int recordCount = 0;
66 104
                 if (!string.IsNullOrWhiteSpace(sql))
@@ -71,113 +109,22 @@ namespace CallCenterApi.Interface.Controllers.workorder
71 109
                         "F_ID",
72 110
                         "*,dbo.GetUserName(F_CreateBy) as F_CreateByName",
73 111
                         sql,
74
-                        "ORDER BY F_CustomerId desc",
112
+                        "ORDER BY T_Wo_WorkOrder.F_ID desc",
75 113
                         pagesize,
76 114
                         pageindex,
77 115
                         true,
78 116
                         out recordCount);
79 117
                 }
80
-                int total = 0;
81
-                List<long> woid = new List<long>();
82 118
                 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
-                Model.T_Sys_RoleInfo ro = rolebll .GetModel(ua.F_RoleId);
86
-                if (ro.F_RoleCode  == "JDYPTZX" || ro.F_RoleCode == "YWY" )
87
-                {
88
-                    if (modlelist.Count >0)
89
-                    {
90
-                        foreach (var it in modlelist)
91
-                        {
92
-                            if (it.F_DealBy == ua.F_UserCode)
93
-                            {
94
-                                list.Add(it);
95
-                                total++;
96
-                            }
97
-                        }
98
-                    }
99
-                  
100
-                }
101
-               else  if (ro.F_RoleCode == "BLRY" || ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
102
-                {
103
-                    List<int> detpid = new List<int>();
104
-                    var deparmentlist = new List<Model.T_Sys_Department>();
105
-                    Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
106
-                    if (dModel != null)
107
-                    {
108
-
109
-                        if (dModel.F_Layer == 1)
110
-                        {
111
-                            deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
112
-                            if (deparmentlist.Count > 0)
113
-                            {
114
-                                foreach (var it in deparmentlist)
115
-                                {
116
-                                    detpid.Add(it.F_DeptId);
117
-                                  
118
-                                }
119
-                            }
120
-                        }
121
-                        detpid.Add(dModel.F_DeptId);
122
-                        var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' " + " ");
123
-                        if (itemlast.Count > 0)
124
-                        {
125
-                            foreach (var it in itemlast)
126
-                            {
127
-                                for (int i = 0; i < detpid.Count; i++)
128
-                                {
129
-                                    if (it.F_NextDept == detpid[i])
130
-                                    {
131
-                                        woid.Add(it.F_WoID);
132
-                                    }
133
-                                }
134
-                            }
135
-                        }
136
-                        if (modlelist.Count >0 && woid.Count > 0)
137
-                        {
138
-                            foreach (var it in modlelist)
139
-                            {
140
-                                for (int i = 0; i < woid.Count; i++)
141
-                                {
142
-                                    if (it.F_ID == woid[i])
143
-                                    {
144
-                                        list.Add(it);
145
-                                        total++;
146
-                                    }
147
-                                }
148
-                            }
149
-                        }
150
-                       
151
-                    }
152
-                    else
153
-                    {
154
-                        return Error("加载失败");
155
-                    }
156
-                }
157
-                else if (ro.F_RoleCode == "QTJS")
158
-                {
159
-                    return Error("无操作权限!");
160
-                }
161
-                else
119
+                if (modlelist.Count > 0)
162 120
                 {
163
-                    if (modlelist.Count > 0 )
164
-                    {
165
-                        foreach (var it in modlelist)
166
-                        {
167
-                           list.Add(it);
168
-                            total++;
169
-                        }
170
-                    }
171
-                }
172
-                if (list.Count >0)
173
-                {
174
-                    List<WorkOrderNewInput> Input = modeltooip(list);
121
+                    List<WorkOrderNewInput> Input = modeltooip(modlelist);
175 122
                     var obj = new
176 123
                     {
177 124
                         state = "success",
178 125
                         message = "成功",
179 126
                         rows = Input,
180
-                        total = total
127
+                        total = recordCount
181 128
                     };
182 129
 
183 130
                     return Content(obj.ToJson()); ;
@@ -185,83 +132,182 @@ namespace CallCenterApi.Interface.Controllers.workorder
185 132
                 else
186 133
                 {
187 134
 
188
-                    return Success ("暂无工单"); ;
135
+                    return Success("暂无工单"); ;
189 136
                 }
190
-               
191
-
192 137
             }
193 138
             else
194 139
             {
195 140
                 return Error("无操作权限!");
196 141
             }
197
-           
142
+            #region 
143
+            // if (ro.F_RoleCode  == "JDYPTZX" || ro.F_RoleCode == "YWY" )
144
+            // {
145
+
146
+            //     if (modlelist.Count >0)
147
+            //     {
148
+            //         foreach (var it in modlelist)
149
+            //         {
150
+            //             var itemlast = itembll.GetModelList(" F_ItemType=" + (int)EnumItemType.deal + " and  F_WoID='" + it.F_ID  + "' order by F_CreateTime desc").FirstOrDefault();
151
+            //             if (itemlast != null)
152
+
153
+            //             if (it.F_DealBy == ua.F_UserCode)
154
+            //             {
155
+            //                 list.Add(it);
156
+            //                 total++;
157
+            //             }
158
+            //         }
159
+            //     }
160
+
161
+            // }
162
+            //else  if (ro.F_RoleCode == "BLRY" || ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
163
+            // { 
164
+            //     List<int> detpid = new List<int>();
165
+            //     var deparmentlist = new List<Model.T_Sys_Department>();
166
+            //     Model.T_Sys_Department dModel = departmentBLL.GetModel(ua.F_DeptId);
167
+            //     if (dModel != null)
168
+            //     {
169
+
170
+            //         if (dModel.F_Layer == 1)
171
+            //         {
172
+            //             deparmentlist = new BLL.T_Sys_Department().GetModelList(" F_State=1 and F_Layer=" + 2 + " and F_ParentId=" + dModel.F_DeptId);
173
+            //             if (deparmentlist.Count > 0)
174
+            //             {
175
+            //                 foreach (var it in deparmentlist)
176
+            //                 {
177
+            //                     detpid.Add(it.F_DeptId);
178
+
179
+            //                 }
180
+            //             }
181
+            //         }
182
+            //         detpid.Add(dModel.F_DeptId);
183
+            //         var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' " + " ");
184
+            //         if (itemlast.Count > 0)
185
+            //         {
186
+            //             foreach (var it in itemlast)
187
+            //             {
188
+            //                 for (int i = 0; i < detpid.Count; i++)
189
+            //                 {
190
+            //                     if (it.F_NextDept == detpid[i])
191
+            //                     {
192
+            //                         woid.Add(it.F_WoID);
193
+            //                     }
194
+            //                 }
195
+            //             }
196
+            //         }
197
+            //         if (modlelist.Count >0 && woid.Count > 0)
198
+            //         {
199
+            //             foreach (var it in modlelist)
200
+            //             {
201
+            //                 for (int i = 0; i < woid.Count; i++)
202
+            //                 {
203
+            //                     if (it.F_ID == woid[i])
204
+            //                     {
205
+            //                         list.Add(it);
206
+            //                         total++;
207
+            //                     }
208
+            //                 }
209
+            //             }
210
+            //         }
211
+
212
+            //     }
213
+            //     else
214
+            //     {
215
+            //         return Error("加载失败");
216
+            //     }
217
+            // }
218
+            // else if (ro.F_RoleCode == "QTJS")
219
+            // {
220
+            //     return Error("无操作权限!");
221
+            // }
222
+            // else
223
+            // {
224
+            //     if (modlelist.Count > 0 )
225
+            //     {
226
+            //         foreach (var it in modlelist)
227
+            //         {
228
+            //            list.Add(it);
229
+            //             total++;
230
+            //         }
231
+            //     }
232
+            // }
233
+            #endregion
234
+
198 235
         }
199
-            /// <summary>
200
-            /// 查询工单详情
201
-            /// </summary>
202
-            public ActionResult GetDetails(int id)
236
+        /// <summary>
237
+        /// 获取我参与的工单编号
238
+        /// </summary>
239
+        /// <param name="user"></param>
240
+        /// <returns></returns>
241
+        public string GetCYWorkOrderID(string user)
203 242
         {
204
-            int userId = CurrentUser.UserData.F_UserId;
205
-            if (userId != 0)
206
-            {
207
-                Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
208
-                string sql = "";
209
-                if (id > 0)
210
-                {
211
-                    sql += $" ( F_ID like '%" + id + "%' ) ";
212
-                }
213
-                else
214
-                    return Error("请输入正确的id");
215
-                var list = new List<Model.T_Wo_WorkOrder>();
216
-                if (!string.IsNullOrWhiteSpace(sql))
217
-                {
218
-                    sql += " and F_IsDelete=0";
219
-                    list = workOrder.GetModelList(sql);
220
-                }
221
-                var itemlasts = itembll.GetModelList("  F_ItemType=" + (int)EnumItemType.deal + " and  F_WoID=" + id + " ");
243
+            string str = string.Empty;
222 244
 
223
-                if (list.Count > 0)
245
+            str = "select F_WoID from T_Wo_WorkOrderItem_New where F_CreateUser='" + user + "' ";
246
+
247
+            return str;
248
+        }
249
+        /// <summary>
250
+        /// 获取待完成的工单编号
251
+        /// </summary>
252
+        /// <returns></returns>
253
+        public string GetDWCWorkOrderID(string user)
254
+        {
255
+            string str = string.Empty;
256
+
257
+            str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
258
+                + " and ("
259
+                    + "(F_WoState in(" + (int)EnumWorkOrderState.dealing + "," + (int)EnumWorkOrderState.receive + ") and F_CreateUser='" + user + "') "//办理中和接单状态的操作人
260
+                    + " or (F_WoState in(" + (int)EnumWorkOrderState.reback + "," + (int)EnumWorkOrderState.abreback + ") and F_NextUser='" + user + "')"//退回下一步操作人
261
+                + ")"
262
+                + " and isnull(F_IsUsed,'0')='0' ";
263
+
264
+            return str;
265
+        }
266
+        /// <summary>
267
+        /// 获取待接单的工单编号
268
+        /// </summary>
269
+        /// <returns></returns>
270
+        public string GetDJDWorkOrderID(string user)
271
+        {
272
+            string str = string.Empty;
273
+            var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_ItemType=" + (int)EnumItemType.deal + " and  F_WoState=" + (int)EnumWorkOrderState.assign + " ");
274
+            //   str = "select F_WoID from T_Wo_WorkOrderItem_New where F_ItemType=" + (int)EnumItemType.deal
275
+            //    + " and F_WoState=" + (int)EnumWorkOrderState.assign
276
+            //    + " and isnull(F_IsUsed,'0')='0' and F_NextUser='" + user + "' ";
277
+            foreach (var it in itemlast )
278
+            {
279
+               
280
+                string[] code = it.F_NextUser.Split(','); 
281
+                for (int i=0;i< code.Length;i++)
224 282
                 {
225
-                    List<WorkOrderNewInput> Input = modeltooip(list);
226
-                    if (Input !=null )
283
+                    if (code [i ]==user )
227 284
                     {
228
-                        var obj = new
285
+                      if (str !=string .Empty )
229 286
                         {
230
-                            state = "success",
231
-                            message = "成功",
232
-                            rows = Input,
233
-                            total= itemlasts,
234
-                        };
235
-
236
-                        return Content(obj.ToJson()); 
237
-                    }
238
-                    else
239
-                    {
240
-                        return Error("没有查询到此工单");
287
+                            str = str + "," + it .F_WoID ;
288
+                        }
289
+                      else
290
+                        {
291
+                            str = it.F_WoID+"";
292
+                        }
241 293
                     }
242 294
                 }
243
-                else
244
-                    return Error("没有查询到此工单");
245
-
246
-            }
247
-            else
248
-            {
249
-                return Error("无操作权限!");
250 295
             }
296
+            return str;
251 297
         }
252 298
         /// <summary>
253
-        /// 查询参与工单列表
299
+        /// 查询工单详情
254 300
         /// </summary>
255
-        public ActionResult GetParticipate()
301
+        public ActionResult GetDetails(int id)
256 302
         {
257 303
             int userId = CurrentUser.UserData.F_UserId;
258 304
             if (userId != 0)
259 305
             {
260 306
                 Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
261 307
                 string sql = "";
262
-                if (ua!=null )
308
+                if (id > 0)
263 309
                 {
264
-                    sql += $" ( F_DealBy like '%" + ua.F_UserCode  + "%' ) ";
310
+                    sql += $" ( F_ID like '%" + id + "%' ) ";
265 311
                 }
266 312
                 else
267 313
                     return Error("请输入正确的id");
@@ -271,29 +317,30 @@ namespace CallCenterApi.Interface.Controllers.workorder
271 317
                     sql += " and F_IsDelete=0";
272 318
                     list = workOrder.GetModelList(sql);
273 319
                 }
274
-              
320
+                var itemlasts = itembll.GetModelList("  F_ItemType=" + (int)EnumItemType.deal + " and  F_WoID=" + id + " ");
275 321
 
276 322
                 if (list.Count > 0)
277 323
                 {
278 324
                     List<WorkOrderNewInput> Input = modeltooip(list);
279
-                    if (Input != null)
325
+                    if (Input !=null )
280 326
                     {
281 327
                         var obj = new
282 328
                         {
283 329
                             state = "success",
284 330
                             message = "成功",
285 331
                             rows = Input,
332
+                            total= itemlasts,
286 333
                         };
287 334
 
288
-                        return Content(obj.ToJson());
335
+                        return Content(obj.ToJson()); 
289 336
                     }
290 337
                     else
291 338
                     {
292
-                        return Error("暂无参与工单");
339
+                        return Error("没有查询到此工单");
293 340
                     }
294 341
                 }
295 342
                 else
296
-                    return Error("暂无参与工单");
343
+                    return Error("没有查询到此工单");
297 344
 
298 345
             }
299 346
             else
@@ -302,10 +349,10 @@ namespace CallCenterApi.Interface.Controllers.workorder
302 349
             }
303 350
         }
304 351
         /// <summary>
305
-        /// 查询超时工单列表
352
+        ///综合查询列表
306 353
         /// </summary>
307
-        public ActionResult GetOvertime(string code, string cusname, string cusphone, string companyname, string province, string city,
308
-            string country, string township, string touser, int type = 0, int state = -1, int pageindex = 1, int pagesize = 10)
354
+        public ActionResult GetComprehensive(string code, string cusname, string cusphone, string companyname, string province, string city,
355
+            string country, string township, string touser, int source = 0, int type = 0, int state = 0, int pageindex = 1, int pagesize = 10)
309 356
         {
310 357
             int userId = CurrentUser.UserData.F_UserId;
311 358
             if (userId != 0)
@@ -317,6 +364,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
317 364
                     sql += $" and F_Type=" + type;
318 365
                 if (state >= 0)//工单状态
319 366
                     sql += $" and F_State=" + state;
367
+                if (source > 0)//工单来源
368
+                    sql += $" and F_Source=" + source;
320 369
                 if (!string.IsNullOrWhiteSpace(touser))//参与人
321 370
                     sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
322 371
                 if (!string.IsNullOrWhiteSpace(code))//工单编号
@@ -357,7 +406,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
357 406
                 List<Model.T_Wo_WorkOrder> list = new List<Model.T_Wo_WorkOrder>();
358 407
                 Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
359 408
                 Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
360
-                if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "YWY" || ro.F_RoleCode == "BLRY")
409
+                if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "YWY" )
361 410
                 {
362 411
                     if (modlelist.Count > 0)
363 412
                     {
@@ -365,17 +414,13 @@ namespace CallCenterApi.Interface.Controllers.workorder
365 414
                         {
366 415
                             if (it.F_DealBy == ua.F_UserCode)
367 416
                             {
368
-                                if (it.F_IsOver == 1)
369
-                                {
370 417
                                     list.Add(it);
371 418
                                     total++;
372
-                                }
373 419
                             }
374 420
                         }
375 421
                     }
376
-
377 422
                 }
378
-                else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
423
+                else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "BLRY" || ro.F_RoleCode == "ZG")
379 424
                 {
380 425
                     List<int> detpid = new List<int>();
381 426
                     var deparmentlist = new List<Model.T_Sys_Department>();
@@ -434,24 +479,6 @@ namespace CallCenterApi.Interface.Controllers.workorder
434 479
                         return Error("加载失败");
435 480
                     }
436 481
                 }
437
-                else if (ro.F_RoleCode == "JDYBZZX")
438
-                 {
439
-                    if (modlelist.Count>0 )
440
-                    {
441
-                        foreach (var it in modlelist)
442
-                        {
443
-                           
444
-                                if (it.F_CreateBy  ==ua .F_UserCode )
445
-                                {
446
-                                if (it.F_IsOver == 1)
447
-                                {
448
-                                    list.Add(it);
449
-                                    total++;
450
-                                }
451
-                                }
452
-                        }
453
-                    }
454
-                }
455 482
                 else if (ro.F_RoleCode == "QTJS")
456 483
                 {
457 484
                     return Error("无操作权限!");
@@ -462,11 +489,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
462 489
                     {
463 490
                         foreach (var it in modlelist)
464 491
                         {
465
-                            if (it.F_IsOver == 1)
466
-                            {
467 492
                                 list.Add(it);
468 493
                                 total++;
469
-                            }
470 494
                         }
471 495
                     }
472 496
                 }
@@ -494,15 +518,12 @@ namespace CallCenterApi.Interface.Controllers.workorder
494 518
                 return Error("无操作权限!");
495 519
             }
496 520
         }
497
-      
498 521
         /// <summary>
499
-        /// 获取催办工单列表
522
+        /// 查询超时工单列表
500 523
         /// </summary>
501
-        /// <returns></returns>
502
-        public ActionResult GetUrgeList(string code, string cusname, string cusphone, string companyname, string province, string city,
503
-            string country, string township, string touser, int type = 0, int state = -1, int pageindex = 1, int pagesize = 10)
524
+        public ActionResult GetOvertime(string code, string cusname, string cusphone, string companyname, string province, string city,
525
+            string country, string township, string touser, int source = 0, int type = 0, int state = 0, int pageindex = 1, int pagesize = 10)
504 526
         {
505
-           
506 527
             int userId = CurrentUser.UserData.F_UserId;
507 528
             if (userId != 0)
508 529
             {
@@ -513,6 +534,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
513 534
                     sql += $" and F_Type=" + type;
514 535
                 if (state >= 0)//工单状态
515 536
                     sql += $" and F_State=" + state;
537
+                if (source > 0)//工单来源
538
+                    sql += $" and F_Source=" + source;
516 539
                 if (!string.IsNullOrWhiteSpace(touser))//参与人
517 540
                     sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
518 541
                 if (!string.IsNullOrWhiteSpace(code))//工单编号
@@ -553,37 +576,25 @@ namespace CallCenterApi.Interface.Controllers.workorder
553 576
                 List<Model.T_Wo_WorkOrder> list = new List<Model.T_Wo_WorkOrder>();
554 577
                 Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
555 578
                 Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
556
-                var itemlasts = itembll.GetModelList("  F_ItemType=" + (int)EnumItemType.urge + " ");
557
-                if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "YWY")
579
+                if (ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "YWY" || ro.F_RoleCode == "BLRY")
558 580
                 {
559
-                    woid.Clear();
560
-                    if (itemlasts.Count > 0)
561
-                    {
562
-                        foreach (var it in itemlasts)
563
-                        {
564
-                          woid.Add(it.F_WoID);
565
-                        }
566
-                    }
567 581
                     if (modlelist.Count > 0)
568 582
                     {
569 583
                         foreach (var it in modlelist)
570 584
                         {
571 585
                             if (it.F_DealBy == ua.F_UserCode)
572 586
                             {
573
-                                for (int i = 0; i < woid.Count; i++)
587
+                                if (it.F_IsOver == 1)
574 588
                                 {
575
-                                    if (it.F_ID == woid[i])
576
-                                    {
577
-                                        list.Add(it);
578
-                                        total++;
579
-                                    }
589
+                                    list.Add(it);
590
+                                    total++;
580 591
                                 }
581 592
                             }
582 593
                         }
583 594
                     }
584 595
 
585 596
                 }
586
-                else if (ro.F_RoleCode == "BLRY" || ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
597
+                else if (ro.F_RoleCode == "DQJL" || ro.F_RoleCode == "FGSJL" || ro.F_RoleCode == "ZG")
587 598
                 {
588 599
                     List<int> detpid = new List<int>();
589 600
                     var deparmentlist = new List<Model.T_Sys_Department>();
@@ -604,10 +615,10 @@ namespace CallCenterApi.Interface.Controllers.workorder
604 615
                             }
605 616
                         }
606 617
                         detpid.Add(dModel.F_DeptId);
607
-                      
608
-                        if (itemlasts.Count > 0)
618
+                        var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' " + " ");
619
+                        if (itemlast.Count > 0)
609 620
                         {
610
-                            foreach (var it in itemlasts)
621
+                            foreach (var it in itemlast)
611 622
                             {
612 623
                                 for (int i = 0; i < detpid.Count; i++)
613 624
                                 {
@@ -626,8 +637,11 @@ namespace CallCenterApi.Interface.Controllers.workorder
626 637
                                 {
627 638
                                     if (it.F_ID == woid[i])
628 639
                                     {
629
-                                        list.Add(it);
630
-                                        total++;
640
+                                        if (it.F_IsOver == 1)
641
+                                        {
642
+                                            list.Add(it);
643
+                                            total++;
644
+                                        }
631 645
                                     }
632 646
                                 }
633 647
                             }
@@ -639,31 +653,38 @@ namespace CallCenterApi.Interface.Controllers.workorder
639 653
                         return Error("加载失败");
640 654
                     }
641 655
                 }
656
+                else if (ro.F_RoleCode == "JDYBZZX")
657
+                 {
658
+                    if (modlelist.Count>0 )
659
+                    {
660
+                        foreach (var it in modlelist)
661
+                        {
662
+                           
663
+                                if (it.F_CreateBy  ==ua .F_UserCode )
664
+                                {
665
+                                if (it.F_IsOver == 1)
666
+                                {
667
+                                    list.Add(it);
668
+                                    total++;
669
+                                }
670
+                                }
671
+                        }
672
+                    }
673
+                }
642 674
                 else if (ro.F_RoleCode == "QTJS")
643 675
                 {
644 676
                     return Error("无操作权限!");
645 677
                 }
646 678
                 else
647 679
                 {
648
-                    woid.Clear();
649
-                    if (itemlasts.Count > 0)
650
-                    {
651
-                        foreach (var it in itemlasts)
652
-                        {
653
-                            woid.Add(it.F_WoID);
654
-                        }
655
-                    }
656 680
                     if (modlelist.Count > 0)
657 681
                     {
658 682
                         foreach (var it in modlelist)
659 683
                         {
660
-                            for (int i = 0; i < woid.Count; i++)
684
+                            if (it.F_IsOver == 1)
661 685
                             {
662
-                                if (it.F_ID == woid[i])
663
-                                {
664
-                                    list.Add(it);
665
-                                    total++;
666
-                                }
686
+                                list.Add(it);
687
+                                total++;
667 688
                             }
668 689
                         }
669 690
                     }
@@ -686,8 +707,86 @@ namespace CallCenterApi.Interface.Controllers.workorder
686 707
 
687 708
                     return Success("暂无工单"); ;
688 709
                 }
710
+            }
711
+            else
712
+            {
713
+                return Error("无操作权限!");
714
+            }
715
+        }
716
+      
717
+        /// <summary>
718
+        /// 获取催办工单列表
719
+        /// </summary>
720
+        /// <returns></returns>
721
+        public ActionResult GetUrgeList(string code, string cusname, string cusphone, string companyname, string province, string city,
722
+            string country, string township, string touser,int source=0, int type = 0, int state = -1, int pageindex = 1, int pagesize = 10)
723
+        {
724
+           
725
+            int userId = CurrentUser.UserData.F_UserId;
726
+            if (userId != 0)
727
+            {
728
+                string sql = $" and F_IsDelete=0";
729
+                DataTable dt = new DataTable();
730
+                #region 筛选条件
731
+                if (type > 0 && type < 4)//工单类型
732
+                    sql += $" and F_Type=" + type;
733
+                if (state >= 0)//工单状态
734
+                    sql += $" and F_State=" + state;
735
+                if (source >= 0)//工单状态
736
+                    sql += $" and F_Source=" + source;
737
+                if (!string.IsNullOrWhiteSpace(touser))//参与人
738
+                    sql += $" and F_DealBy like '%" + touser.Trim() + "%'";
739
+                if (!string.IsNullOrWhiteSpace(code))//工单编号
740
+                    sql += $" and F_WorkOrderCode like '%" + code.Trim() + "%'";
741
+                if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
742
+                    sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
743
+                if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
744
+                    sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
745
+                if (!string.IsNullOrWhiteSpace(companyname))//公司名称
746
+                    sql += $" and F_CompanyName like '%" + companyname.Trim() + "%'";
747
+                if (!string.IsNullOrWhiteSpace(province))//省
748
+                    sql += $" and F_IncidentProvince like '%" + province.Trim() + "%'";
749
+                if (!string.IsNullOrWhiteSpace(province))//市
750
+                    sql += $" and F_IncidentCity like '%" + city.Trim() + "%'";
751
+                if (!string.IsNullOrWhiteSpace(province))//县
752
+                    sql += $" and F_IncidentCountry like '%" + country.Trim() + "%'";
753
+                if (!string.IsNullOrWhiteSpace(province))//乡
754
+                    sql += $" and F_IncidentTownship like '%" + township.Trim() + "%'";
755
+                #endregion
756
+                int recordCount = 0;
757
+                if (!string.IsNullOrWhiteSpace(sql))
758
+                {
689 759
 
760
+                    dt = BLL.PagerBLL.GetListPager(
761
+                        "T_Wo_WorkOrder",
762
+                        "F_ID",
763
+                        "*,dbo.GetUserName(F_CreateBy) as F_CreateByName",
764
+                        sql,
765
+                       "ORDER BY T_Wo_WorkOrder.F_ID desc",
766
+                        pagesize,
767
+                        pageindex,
768
+                        true,
769
+                        out recordCount);
770
+                    dt.Columns.Add("CBCount", typeof(int));
771
+                    foreach (DataRow dr in dt.Rows)
772
+                    {
773
+                        var list = itembll.GetList(" F_WoID ='" + dr["ID"].ToString() + "' and F_ItemType=" + (int)EnumItemType.urge).Tables[0];
774
+                        dr["CBCount"] = list.Rows.Count;
775
+                    }
690 776
 
777
+                    var obj = new
778
+                    {
779
+                        state = "success",
780
+                        message = "成功",
781
+                        rows = dt,
782
+                        total = recordCount
783
+                    };
784
+                    return  Content(obj.ToJson());
785
+                }
786
+                else
787
+                {
788
+                    return Success("暂无工单"); ;
789
+                }
691 790
             }
692 791
             else
693 792
             {
@@ -750,21 +849,33 @@ namespace CallCenterApi.Interface.Controllers.workorder
750 849
             {
751 850
                 if (ids != null && ids.Length > 0)
752 851
                 {
852
+                      bool res = true;
753 853
                     string idd = " ";
754 854
                     foreach (string str in ids)
755 855
                     {
756 856
                         idd += str + ",";
757 857
                     }
858
+            
758 859
                     if (!string.IsNullOrEmpty(idd.Trim()))
759 860
                     {
760
-                        if (workOrder.DeleteList(idd.TrimEnd(',')))
761
-                        {
762
-                            return Success("设置成功");
861
+                        if (itembll .DeleteList (idd.TrimEnd(',')))
862
+                          {
863
+                            if (workOrder.DeleteList(idd.TrimEnd(',')))
864
+                            {
865
+
866
+                                return Success("设置成功");
867
+
868
+                            }
869
+                            else
870
+                            {
871
+                                return Error("设置失败");
872
+                            }
763 873
                         }
764 874
                         else
765 875
                         {
766 876
                             return Error("设置失败");
767 877
                         }
878
+                       
768 879
                     }
769 880
                     else
770 881
                     {
@@ -1224,7 +1335,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1224 1335
         /// <summary>
1225 1336
         /// 添加工单记录
1226 1337
         /// </summary>
1227
-        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 )
1338
+        public long AddLog(long woid, int wostate, string content, int itemtype, int opttype, string nextuser, int nextdept, Model.T_Sys_UserAccount nowUser ,float  overtime,int sms )
1228 1339
         {
1229 1340
             Model.T_Wo_WorkOrderItem_New itemModel = new Model.T_Wo_WorkOrderItem_New();
1230 1341
             #region 
@@ -1277,7 +1388,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1277 1388
         /// <returns></returns>
1278 1389
         
1279 1390
         [Authority]
1280
-        public ActionResult AssignWorkOrder(long orderid, string cont,int overtime=0,int sms=0,int clbm = 0, int clid = 0)
1391
+        public ActionResult AssignWorkOrder(long orderid, string cont, float overtime =0,int sms=0,int clbm = 0, int clid = 0)
1281 1392
         {
1282 1393
             int userId = CurrentUser.UserData.F_UserId;
1283 1394
             string usercode = CurrentUser.UserData.F_UserCode;
@@ -1291,7 +1402,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1291 1402
               
1292 1403
                 if (ua != null)
1293 1404
                 {
1294
-                    if (clbm != 0 && clid == 0)
1405
+                    if (clbm == 0 && clid == 0)
1295 1406
                     {
1296 1407
                         return Error("请选择接收人");
1297 1408
                     }
@@ -1304,12 +1415,12 @@ namespace CallCenterApi.Interface.Controllers.workorder
1304 1415
                             {
1305 1416
                                 if (model.F_Type  == "2")
1306 1417
                                 {
1307
-                                    if (deptmodel.F_DeptName == "市场管理科")
1418
+                                    if (deptmodel.F_DeptId  == 37)
1308 1419
                                     {
1309 1420
                                         input. F_SC_QualityMonth = RequestString.GetQueryString("QualityMonth");//市场管理科-超出质保期限
1310 1421
                                         input.F_SC_PreliminaryOpinion = RequestString.GetQueryString("PreliminaryOpinion");//市场管理科-初审意见:退货、换货、补偿、自行处理
1311 1422
                                     }
1312
-                                    else if (deptmodel.F_DeptName == "质量管理部")
1423
+                                    else if (deptmodel.F_DeptId  == 12)
1313 1424
                                     {
1314 1425
                                         input.F_IsVisit = RequestString.GetQueryInt("isvisit");
1315 1426
                                         input.F_ZL_QualityEventLevel = RequestString.GetQueryString("QualityEventLevel");//质量管理科-质量事件等级(未遂、一般、较大、重大)
@@ -1328,14 +1439,14 @@ namespace CallCenterApi.Interface.Controllers.workorder
1328 1439
                                 }
1329 1440
                                 else if (model.F_Type == "3")
1330 1441
                                 {
1331
-                                    if (deptmodel.F_DeptName == "市场管理科")
1442
+                                    if (deptmodel.F_DeptId == 37)
1332 1443
                                     {
1333 1444
                                         input.F_SC_CJ_SpotResult = RequestString.GetQueryString("SpotResult");//市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
1334 1445
                                         input.F_SC_CJ_SelfResult = RequestString.GetQueryString("SelfResult");//市场管理科-抽检-自检结果
1335 1446
                                         input.F_SC_CJ_ApprovalNo = RequestString.GetQueryString("ApprovalNo");//市场管理科-抽检-对应审批工作流单号
1336 1447
                                         input.F_SC_CJ_ReturnAccount = RequestString.GetQueryString("ReturnAccount");//市场管理科-抽检-对应审批工作流单号
1337 1448
                                     }
1338
-                                    else if (deptmodel.F_DeptName == "质量管理部")
1449
+                                    else if (deptmodel.F_DeptId == 12)
1339 1450
                                     {
1340 1451
                                         input.F_ZL_CJ_IsRecord = RequestString.GetQueryString("IsRecord");//质量管理科-抽检-未备案、已备案
1341 1452
                                         input.F_ZL_ClaimAmount = RequestString.GetQueryString("ClaimAmount");// 质量管理科-索赔金额(单位元,对应责任单位)
@@ -1418,12 +1529,12 @@ namespace CallCenterApi.Interface.Controllers.workorder
1418 1529
                         {
1419 1530
                             if (model.F_Type == "2")
1420 1531
                             {
1421
-                                if (deptmodel.F_DeptName == "市场管理科")
1532
+                                if (deptmodel.F_DeptId == 37)
1422 1533
                                 {
1423 1534
                                     input.F_SC_ProductBase = RequestString.GetQueryString("ProductBase");//市场管理科-超出质保期限
1424 1535
                                     
1425 1536
                                 }
1426
-                                else if (deptmodel.F_DeptName == "质量管理部")
1537
+                                else if (deptmodel.F_DeptId ==12)
1427 1538
                                 {
1428 1539
                                     input.F_IsVisit  = RequestString.GetQueryInt ("isvisit");
1429 1540
                                     input.F_ZL_QualityEventLevel = RequestString.GetQueryString("QualityEventLevel");//质量管理科-质量事件等级(未遂、一般、较大、重大)
@@ -1442,14 +1553,14 @@ namespace CallCenterApi.Interface.Controllers.workorder
1442 1553
                             }
1443 1554
                             else if (model.F_Type =="3")
1444 1555
                             {
1445
-                                if (deptmodel.F_DeptName == "市场管理科")
1556
+                                if (deptmodel.F_DeptId ==37)
1446 1557
                                 {
1447 1558
                                     input.F_SC_CJ_SpotResult = RequestString.GetQueryString("SpotResult");//市场管理科-抽检-抽检结果(视同合格、合格、不合格、复检后合格、未送检)
1448 1559
                                     input.F_SC_CJ_SelfResult = RequestString.GetQueryString("SelfResult");//市场管理科-抽检-自检结果
1449 1560
                                     input.F_SC_CJ_ApprovalNo = RequestString.GetQueryString("ApprovalNo");//市场管理科-抽检-对应审批工作流单号
1450 1561
                                     input.F_SC_CJ_ReturnAccount = RequestString.GetQueryString("ReturnAccount");//市场管理科-抽检-确认返账金额(元)
1451 1562
                                 }
1452
-                                else if (deptmodel.F_DeptName == "质量管理部")
1563
+                                else if (deptmodel.F_DeptId == 12)
1453 1564
                                 {
1454 1565
                                     input.F_ZL_CJ_IsRecord = RequestString.GetQueryString("IsRecord");//质量管理科-抽检-未备案、已备案
1455 1566
                                 }
@@ -1487,6 +1598,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1487 1598
             int userId = CurrentUser.UserData.F_UserId;
1488 1599
             if (userId != 0)
1489 1600
             {
1601
+                //河南心连心化学工业集团股份有限公司-系统维护管理员(8000)指派工单给 李波(80324),张绍申(80325),杜爱国(80326),说明:无
1490 1602
                 Model.T_Sys_UserAccount ua = sysUserAccountBll.GetModel(userId);
1491 1603
                 if (ua != null)
1492 1604
                 {
@@ -1876,12 +1988,15 @@ namespace CallCenterApi.Interface.Controllers.workorder
1876 1988
                 #endregion
1877 1989
                 #region 读取上一级指派人员推送系统消息和微信消息
1878 1990
                 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();
1879
-                if (itemlast.F_CreateUser != model.F_CreateBy)
1991
+                if (itemlast!=null )
1880 1992
                 {
1881
-                    sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, "处理接单");
1882
-                    var lastUser = sysUserAccountBll.GetModel(itemlast.F_CreateUser);
1883
-                  //  if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
1884
-                     //   sendwxmsg(model, lastUser.F_WxOpenId, nowUser, "接单");
1993
+                    if (itemlast.F_CreateUser != model.F_CreateBy)
1994
+                    {
1995
+                        sendsysmsg(model, nowUser, itemlast.F_CreateUser, (int)itemid, "处理接单");
1996
+                        var lastUser = sysUserAccountBll.GetModel(itemlast.F_CreateUser);
1997
+                        //  if (lastUser != null && !string.IsNullOrEmpty(lastUser.F_WxOpenId))
1998
+                        //   sendwxmsg(model, lastUser.F_WxOpenId, nowUser, "接单");
1999
+                    }
1885 2000
                 }
1886 2001
                 #endregion
1887 2002
                 #endregion
@@ -1928,7 +2043,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1928 2043
         /// <summary>
1929 2044
         /// 转派工单
1930 2045
         /// </summary>
1931
-        public bool AssignWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, WorkOrderNewInput input, string cont, int clbm = 0, int clid = 0,int overtime = 0, int sms = 0)
2046
+        public bool AssignWO(Model.T_Sys_UserAccount nowUser, Model.T_Wo_WorkOrder model, WorkOrderNewInput input, string cont, int clbm = 0, int clid = 0, float overtime = 0, int sms = 0)
1932 2047
         {
1933 2048
             string touser = ""; string tousername = "";
1934 2049
             #region 获取接收人
@@ -1982,7 +2097,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1982 2097
             {
1983 2098
                 #region 处理工单
1984 2099
                 //工单完结要更新工单的状态
1985
-                model.F_DealBy = touser;
2100
+             //   model.F_DealBy = touser;
1986 2101
                 model.F_State = wostate;
1987 2102
                 //处理内容
1988 2103
                 if (!string.IsNullOrEmpty(cont))