zhoufan il y a 7 ans
Parent
commit
9765c5def6

+ 45 - 7
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/report/BusinessController.cs

@@ -57,7 +57,7 @@ namespace CallCenterApi.Interface.Controllers.report
57 57
         /// 投诉原因报表
58 58
         /// </summary>
59 59
         /// <returns></returns>
60
-        public ActionResult GetTypeReport(string sdate, string edate)
60
+        public ActionResult GetTypeReport(string sdate, string edate, int isdc = 0)
61 61
         {
62 62
             int userId = CurrentUser.UserData.F_UserId;
63 63
             Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
@@ -88,6 +88,19 @@ namespace CallCenterApi.Interface.Controllers.report
88 88
 
89 89
             DataTable dt = DbHelperSQL.Query(sql).Tables[0];
90 90
 
91
+            if (isdc > 0)
92
+            {
93
+                NPOIHelper npoi = new NPOIHelper();
94
+                if (npoi.ExportToExcel("投诉原因", dt,new string[] { "投诉类型", "数量"}) == "")
95
+                {
96
+                    return Success("导出成功");
97
+                }
98
+                else
99
+                {
100
+                    return Error("导出失败");
101
+                }
102
+            }
103
+
91 104
             return Success("成功", dt);
92 105
         }
93 106
 
@@ -95,7 +108,7 @@ namespace CallCenterApi.Interface.Controllers.report
95 108
         /// 客诉数量报表
96 109
         /// </summary>
97 110
         /// <returns></returns>
98
-        public ActionResult GetWorkMonthCountReport()
111
+        public ActionResult GetWorkMonthCountReport(int isdc = 0)
99 112
         {
100 113
             int userId = CurrentUser.UserData.F_UserId;
101 114
             Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
@@ -137,6 +150,10 @@ namespace CallCenterApi.Interface.Controllers.report
137 150
                 where += " and F_City = '" + strcity.Trim() + "' ";
138 151
             }
139 152
 
153
+            DataTable dt = new DataTable();
154
+            dt.Columns.Add("年月", typeof(string));
155
+            dt.Columns.Add("数量", typeof(string));
156
+
140 157
             int[] ints = new int[12];
141 158
             string[] months = new string[12];
142 159
             for (int i = 12; i > 0; i--)
@@ -145,24 +162,45 @@ namespace CallCenterApi.Interface.Controllers.report
145 162
                 string mon = date.ToString("yyyyMM");
146 163
                 months[12 - i] = mon;
147 164
                 ints[12 - i] = date.Month;
165
+
166
+                DataRow dr = dt.NewRow();
167
+                dr["年月"] = mon;
168
+                dt.Rows.Add(dr);
148 169
             }
149 170
 
150 171
             var obj = new
151 172
             {
152 173
                 months,
153
-                counts = new List<int[]>()
174
+                counts = new int[12]
154 175
             };
155 176
 
156 177
             int[] count = new int[12];
157 178
             for (int i = 0; i < ints.Length; i++)
158 179
             {
159
-                string sql = " select count(1) from dbo.T_Bus_WorkOrder where "+ where + " and datepart(month, F_CreateTime)=" + ints[i];
160
-                count[i] = Int32.Parse(DbHelperSQL.Query(sql).Tables[0].Rows[0][0].ToString());
180
+                string sql = " select count(1) from dbo.T_Bus_WorkOrder where " + where + " and datepart(month, F_CreateTime)=" + ints[i];
181
+                obj.counts[i] = Int32.Parse(DbHelperSQL.Query(sql).Tables[0].Rows[0][0].ToString());
182
+                dt.Rows[i]["数量"] = obj.counts[i];
183
+            }
161 184
 
185
+            if (isdc > 0)
186
+            {
187
+                NPOIHelper npoi = new NPOIHelper();
188
+                if (npoi.ExportToExcel("客诉数量", dt) == "")
189
+                {
190
+                    return Success("导出成功");
191
+                }
192
+                else
193
+                {
194
+                    return Error("导出失败");
195
+                }
162 196
             }
163
-            obj.counts.Add(count);
197
+            var result = new
198
+            {
199
+                chartdata = obj,
200
+                list = dt
201
+            };
164 202
 
165
-            return Success("成功", obj);
203
+            return Success("成功", result);
166 204
         }
167 205
     }
168 206
 }