Quellcode durchsuchen

修改工单来源接口

machenyang vor 8 Jahren
Ursprung
Commit
45bccde690

+ 108 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/report/GDLYController.cs

@@ -0,0 +1,108 @@
1
+using CallCenterApi.DB;
2
+using CallCenterApi.Interface.Controllers.Base;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.Data;
6
+using System.Linq;
7
+using System.Web;
8
+using System.Web.Mvc;
9
+
10
+namespace CallCenterApi.Interface.Controllers.report
11
+{
12
+    public class GDLYController : BaseController
13
+    {
14
+        //// GET: GDLY
15
+        //public ActionResult Index()
16
+        //{
17
+        //    return View();
18
+        //}
19
+        /// <summary>
20
+        /// 获取工单来源报表
21
+        /// </summary>
22
+        /// <param name="stime"></param>
23
+        /// <param name="endtime"></param>
24
+        /// <returns></returns>
25
+        public ActionResult GetDataList(string stime, string endtime)
26
+        {
27
+            ActionResult res = NoToken("未知错误,请重新登录");
28
+            DataTable dtNew = new DataTable();
29
+            dtNew = getData(stime, endtime);
30
+            res = Success("获取工单来源数据成功", dtNew);
31
+
32
+            return res;
33
+        }
34
+
35
+        private DataTable getData(string stime, string endtime)
36
+        {
37
+            DataTable dtNew = new DataTable();
38
+            #region 添加表格标题
39
+            DataColumn dc = new DataColumn("坐席人员");
40
+            dtNew.Columns.Add(dc);
41
+            var sqlGDLY = " and F_State=1 and F_DictionaryFlag='GDLY' ";
42
+            var recordCount = 0;
43
+            var dtGDLY = BLL.PagerBLL.GetListPager(
44
+              "T_Sys_DictionaryValue",
45
+              "F_DictionaryValueId",
46
+              "*",
47
+              sqlGDLY,
48
+              "ORDER BY F_Sort ",
49
+              10,
50
+              1,
51
+              true,
52
+              out recordCount);
53
+            List<Model.T_Sys_DictionaryValue> modelList = new BLL.T_Sys_DictionaryValue().DataTableToList(dtGDLY);
54
+
55
+            for (int i = 0; i < modelList.Count; i++)
56
+            {
57
+                string colname = modelList[i].F_Name;
58
+                dtNew.Columns.Add(new DataColumn(colname));
59
+            }
60
+            #endregion
61
+
62
+            string sqltimeCallRecords = "";
63
+            if (stime != null && stime.Trim() != "")
64
+            {
65
+                sqltimeCallRecords += " and CONVERT(varchar , CreateTime, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
66
+            }
67
+            if (endtime != null && endtime.Trim() != "")
68
+            {
69
+                sqltimeCallRecords += " and CONVERT(varchar , CreateTime, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
70
+            }
71
+
72
+            double day = 0;
73
+            if (stime != null && endtime != null && endtime.Trim() != "" && stime.Trim() != "")
74
+            {
75
+                TimeSpan time = Convert.ToDateTime(endtime) - Convert.ToDateTime(stime);
76
+                day = time.Days + 1;
77
+            }
78
+            //获取坐席数据
79
+            DataTable dt = new DataTable();
80
+            string sql = "SELECT * from T_Sys_UserAccount where F_DeleteFlag=0 order by F_Userid asc";
81
+            dt = DbHelperSQL.Query(sql).Tables[0];
82
+            for (int i = 0; i < dt.Rows.Count; i++)
83
+            {
84
+                DataRow drNew = dtNew.NewRow();
85
+                drNew["坐席人员"] = dt.Rows[i]["F_UserName"].ToString();
86
+                //获取工单来源数据
87
+                DataTable dtnew = new DataTable();
88
+                string sqlnew = "select * from T_Sys_DictionaryValue where F_State=1 and F_DictionaryFlag='GDLY'";
89
+                dtnew = DbHelperSQL.Query(sqlnew).Tables[0];
90
+                for (int j = 0; j < dtnew.Rows.Count; j++)
91
+                {
92
+                    string str = "select count(*) from T_Wo_WorkOrder where IsDel=0 and type=" + Convert.ToInt32(dtnew.Rows[j]["F_DictionaryValueId"].ToString()) + " and CreateUserID='" + dt.Rows[i]["F_Userid"].ToString() + "'" + sqltimeCallRecords;
93
+                    DataTable dtj = DbHelperSQL.Query(str).Tables[0];
94
+                    int sum = 0;
95
+                    if (dtj.Rows[0][0] != null && dtj.Rows[0][0].ToString() != "")
96
+                    {
97
+                        sum = Convert.ToInt32(dtj.Rows[0][0]);
98
+                    }
99
+                    drNew[j + 1] = sum.ToString();
100
+                }
101
+                
102
+                dtNew.Rows.Add(drNew);
103
+            }
104
+            
105
+            return dtNew;
106
+        }
107
+    }
108
+}