duhongyu лет назад: 3
Родитель
Сommit
12dd3b4338

+ 23 - 36
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -433,9 +433,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
433 433
 
434 434
             if (deptid != 0)
435 435
             {
436
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
437
-                #region 20190924 zhengbingbing 主办单位查询以最后办理单位为准
438
-                #endregion
436
+                sql += " and  F_MainDeptId in (select F_DeptId from  GetDeptId ('"+ deptid + "'))";
439 437
             }
440 438
 
441 439
 
@@ -1331,10 +1329,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1331 1329
 
1332 1330
             if (deptid != 0)
1333 1331
             {
1334
-
1335
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
1336
-                #region 20190924 zhengbingbing 主办单位查询以最后办理单位为准
1337
-                #endregion
1332
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
1338 1333
             }
1339 1334
             else
1340 1335
             {
@@ -1781,12 +1776,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1781 1776
             }
1782 1777
             if (deptid != 0)
1783 1778
             {
1784
-                //sql += " and ',' + F_MainDeptID + ',' like '%," + deptid.ToString() + ",%'";
1785
-                //sql += " and isnull(F_MainDeptId,null)='" + deptid + "'";
1786
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
1787
-                #region 20190924 zhengbingbing 主办单位查询以最后办理单位为准
1788
-
1789
-                #endregion
1779
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
1790 1780
             }
1791 1781
             else
1792 1782
             {
@@ -2269,11 +2259,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
2269 2259
                     {
2270 2260
                         sql += " and datediff(day,F_CreateTime,'" + strjbendtime + "')>=0   ";
2271 2261
                     }
2272
-                    //if (deptid != 0)
2273
-                    //{
2274
-                    //    //sql += " and ',' + F_MainDeptID + ',' like '%," + deptid.ToString() + ",%'";
2275
-                    //    sql += " and F_MainDeptId = '" + deptid + "'";
2276
-                    //}
2262
+                  
2277 2263
                     if (User.F_RoleCode != "GLY" && User.F_RoleCode != "ZXLDGLY" && User.F_RoleCode != "ZXLDGLYGLY" && User.F_RoleCode != "DDZG"
2278 2264
                         && User.F_RoleCode != "ZXLD" && User.F_RoleCode != "SPZ" && User.F_RoleCode != "SPZJZ")
2279 2265
                     {
@@ -2608,14 +2594,14 @@ namespace CallCenterApi.Interface.Controllers.workorder
2608 2594
             }
2609 2595
             if (deptid != 0)
2610 2596
             {
2611
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
2597
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
2612 2598
             }
2613 2599
             else
2614 2600
             {
2615 2601
                 if (User.F_RoleCode == "WLDW" || User.F_RoleCode == "EJWLDW")
2616 2602
                 {
2617 2603
                     deptid = User.F_DeptId;
2618
-                    sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
2604
+                    sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
2619 2605
                 }
2620 2606
             }
2621 2607
 
@@ -3399,7 +3385,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
3399 3385
             }
3400 3386
             if (deptid != 0)
3401 3387
             {
3402
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
3388
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
3403 3389
             }
3404 3390
             if (ejdeptid > 0)
3405 3391
             {
@@ -3825,7 +3811,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
3825 3811
             }
3826 3812
             if (deptid != 0)
3827 3813
             {
3828
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
3814
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
3829 3815
             }
3830 3816
 
3831 3817
 
@@ -4264,7 +4250,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
4264 4250
             }
4265 4251
             else if (deptid != 0)
4266 4252
             {
4267
-                sql += " and (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
4253
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
4268 4254
             }
4269 4255
 
4270 4256
             sql += ") or F_WorkOrderId in (select F_WorkOrderId from T_Bus_AssignedItemInfo WITH(NOLOCK) where F_State=1 and F_IsDelete=0 and ISNULL(F_FeedbackTime, '')='' ";
@@ -4800,7 +4786,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
4800 4786
             }
4801 4787
             if (deptid != 0)
4802 4788
             {
4803
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
4789
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
4804 4790
             }
4805 4791
 
4806 4792
             if (strpageindex.Trim() != "")
@@ -5234,7 +5220,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
5234 5220
             }
5235 5221
             if (deptid != 0)
5236 5222
             {
5237
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
5223
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
5238 5224
             }
5239 5225
             if (strpageindex.Trim() != "")
5240 5226
             {
@@ -5554,7 +5540,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
5554 5540
 
5555 5541
             if (deptid != 0)
5556 5542
             {
5557
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
5543
+                sql += " and  (F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
5558 5544
             }
5559 5545
             if (dealtype != -1)
5560 5546
             {
@@ -5888,8 +5874,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
5888 5874
             else if (deptid != 0)
5889 5875
             {
5890 5876
                 sqlwhere += " and F_LimitTime<getdate() and F_WorkState NOT IN(6,7,9)";
5891
-                sqlwhere += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
5892
-                sqlwhere1 += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
5877
+                sqlwhere  += " and  F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "'))";
5878
+                sqlwhere1  += " and  F_MainDeptId in (select F_DeptId from  GetDeptId ('" + deptid + "'))";
5893 5879
             }
5894 5880
             else
5895 5881
             {
@@ -6360,9 +6346,10 @@ namespace CallCenterApi.Interface.Controllers.workorder
6360 6346
             {
6361 6347
                 sql += " and F_SourceArea = '" + sourcearea + "' ";
6362 6348
             }
6349
+         
6363 6350
             if (deptid != 0)
6364 6351
             {
6365
-                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
6352
+                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + deptid + "')) and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
6366 6353
                 sql += " and F_WorkOrderID in(" + sqlwhere + ")";
6367 6354
             }
6368 6355
             if (strstarttime.Trim() != "" && strstarttime != "undefined")
@@ -6633,7 +6620,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
6633 6620
             }
6634 6621
             if (deptid != 0)
6635 6622
             {
6636
-                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
6623
+                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + deptid + "')) and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
6637 6624
                 sql += " and F_WorkOrderID in(" + sqlwhere + ")";
6638 6625
             }
6639 6626
             if (strstarttime.Trim() != "" && strstarttime != "undefined")
@@ -6914,7 +6901,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
6914 6901
             }
6915 6902
             if (deptid != 0)
6916 6903
             {
6917
-                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
6904
+                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + deptid + "')) and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
6918 6905
                 sql += " and F_WorkOrderID in(" + sqlwhere + ")";
6919 6906
             }
6920 6907
             if (strstarttime.Trim() != "" && strstarttime != "undefined")
@@ -7156,7 +7143,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
7156 7143
             }
7157 7144
             if (dbdeptid > 0)
7158 7145
             {
7159
-                sql += " and F_WorkOrderId in(select F_WorkOrderId from T_Bus_AssignedInfo  WITH(NOLOCK) where  F_MainDeptId =" + dbdeptid + " )";
7146
+                sql += " and F_WorkOrderId in(select F_WorkOrderId from T_Bus_AssignedInfo  WITH(NOLOCK) where  F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + dbdeptid  + "')) )";
7160 7147
             }
7161 7148
 
7162 7149
             if (dealstarttime.Trim() != "" && dealstarttime != "undefined")
@@ -7490,18 +7477,18 @@ namespace CallCenterApi.Interface.Controllers.workorder
7490 7477
             {
7491 7478
                 if (deptlevel == 0)
7492 7479
                 {
7493
-                    string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
7480
+                    string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + deptid + "')) and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
7494 7481
                     sql += " and F_WorkOrderID in(" + sqlwhere + ")";
7495 7482
                 }
7496 7483
                 else
7497 7484
                 {
7498
-                    string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
7485
+                    string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo_Next WITH(NOLOCK) where F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + deptid + "')) and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
7499 7486
                     sql += " and F_WorkOrderID in(" + sqlwhere + ")";
7500 7487
                 }
7501 7488
             }
7502 7489
             if (deptid != 0)
7503 7490
             {
7504
-                sql += " and  (F_MainDeptId = '" + deptid + "' or F_MainDeptID3='" + deptid + "')";
7491
+                sql += " and  (F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + deptid + "')) or F_MainDeptID3='" + deptid + "')";
7505 7492
             }
7506 7493
             #endregion
7507 7494
 
@@ -7892,7 +7879,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
7892 7879
             }
7893 7880
             if (deptid != 0)
7894 7881
             {
7895
-                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
7882
+                string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo WITH(NOLOCK) where F_MainDeptId  in (select F_DeptId from  GetDeptId ('" + deptid + "')) and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
7896 7883
                 sql += " and F_WorkOrderID in(" + sqlwhere + ")";
7897 7884
             }
7898 7885
             if (strstarttime.Trim() != "" && strstarttime != "undefined")