|
|
@@ -1,228 +0,0 @@
|
|
1
|
|
-using CallCenter.Utility;
|
|
2
|
|
-using CallCenterApi.DB;
|
|
3
|
|
-using CallCenterApi.Interface.Controllers.Base;
|
|
4
|
|
-using System;
|
|
5
|
|
-using System.Collections.Generic;
|
|
6
|
|
-using System.Data;
|
|
7
|
|
-using System.Linq;
|
|
8
|
|
-using System.Web;
|
|
9
|
|
-using System.Web.Mvc;
|
|
10
|
|
-
|
|
11
|
|
-namespace CallCenterApi.Interface.Controllers.report
|
|
12
|
|
-{
|
|
13
|
|
- /// <summary>
|
|
14
|
|
- /// 工单投诉类型报表
|
|
15
|
|
- /// </summary>
|
|
16
|
|
- public class WorkOrdersComplaintTypeController : BaseController
|
|
17
|
|
- {
|
|
18
|
|
- BLL.T_Sys_DictionaryValue bllDic = new BLL.T_Sys_DictionaryValue();
|
|
19
|
|
- BLL.T_Wo_WorkOrder bllWo = new BLL.T_Wo_WorkOrder();
|
|
20
|
|
-
|
|
21
|
|
- /// <summary>
|
|
22
|
|
- /// 获取表头
|
|
23
|
|
- /// </summary>
|
|
24
|
|
- /// <returns></returns>
|
|
25
|
|
- public ActionResult GetColumnList()
|
|
26
|
|
- {
|
|
27
|
|
- #region 添加表格标题
|
|
28
|
|
- var columns = new List<string>();
|
|
29
|
|
- columns.Add("投诉类型");
|
|
30
|
|
- columns.Add("结案");
|
|
31
|
|
- columns.Add("未结案");
|
|
32
|
|
- columns.Add("未结案率");
|
|
33
|
|
- #endregion
|
|
34
|
|
- return Success("获取投诉类型标题成功", columns);
|
|
35
|
|
- }
|
|
36
|
|
-
|
|
37
|
|
- /// <summary>
|
|
38
|
|
- /// 获取投诉类型报表
|
|
39
|
|
- /// </summary>
|
|
40
|
|
- /// <param name="areaid">区域</param>
|
|
41
|
|
- /// <param name="regionid">项目</param>
|
|
42
|
|
- /// <param name="stageid">期</param>
|
|
43
|
|
- /// <param name="iseffective">是否有效</param>
|
|
44
|
|
- /// <param name="gdly">工单类型</param>
|
|
45
|
|
- /// <param name="stime"></param>
|
|
46
|
|
- /// <param name="endtime"></param>
|
|
47
|
|
- /// <returns></returns>
|
|
48
|
|
- public ActionResult GetDataList(string years, int season = 0, int areaid = 0, int regionid = 0, int stageid = 0, int iseffective = -1, int gdly = 0, string stime = "", string endtime = "")
|
|
49
|
|
- {
|
|
50
|
|
- ActionResult res = NoToken("未知错误,请重新登录");
|
|
51
|
|
- DataTable dtNew = new DataTable();
|
|
52
|
|
- dtNew = getData(years, season, areaid, regionid, stageid, iseffective, gdly, stime, endtime);
|
|
53
|
|
- res = Success("获取投诉类型数据成功", dtNew);
|
|
54
|
|
-
|
|
55
|
|
- return res;
|
|
56
|
|
- }
|
|
57
|
|
-
|
|
58
|
|
- /// <summary>
|
|
59
|
|
- /// 获取数据
|
|
60
|
|
- /// </summary>
|
|
61
|
|
- /// <param name="areaid">年份</param>
|
|
62
|
|
- /// <param name="areaid">季度(1234数字)</param>
|
|
63
|
|
- /// <param name="areaid">区域</param>
|
|
64
|
|
- /// <param name="regionid">项目</param>
|
|
65
|
|
- /// <param name="stageid">期</param>
|
|
66
|
|
- /// <param name="iseffective">是否有效</param>
|
|
67
|
|
- /// <param name="gdly">工单类型</param>
|
|
68
|
|
- /// <param name="stime"></param>
|
|
69
|
|
- /// <param name="endtime"></param>
|
|
70
|
|
- /// <returns></returns>
|
|
71
|
|
- private DataTable getData(string years, int season, int areaid, int regionid, int stageid, int iseffective, int gdly, string stime, string endtime)
|
|
72
|
|
- {
|
|
73
|
|
- DataTable dtNew = new DataTable();
|
|
74
|
|
- #region 添加表格标题
|
|
75
|
|
- DataColumn dc1 = new DataColumn("投诉类型", Type.GetType("System.String"));
|
|
76
|
|
- DataColumn dc2 = new DataColumn("结案", Type.GetType("System.String"));
|
|
77
|
|
- DataColumn dc3 = new DataColumn("未结案", Type.GetType("System.String"));
|
|
78
|
|
- DataColumn dc4 = new DataColumn("结案率", Type.GetType("System.String"));
|
|
79
|
|
- DataColumn dc5 = new DataColumn("总计", Type.GetType("System.String"));
|
|
80
|
|
- dtNew.Columns.Add(dc1);
|
|
81
|
|
- dtNew.Columns.Add(dc2);
|
|
82
|
|
- dtNew.Columns.Add(dc3);
|
|
83
|
|
- dtNew.Columns.Add(dc4);
|
|
84
|
|
- dtNew.Columns.Add(dc5);
|
|
85
|
|
- #endregion
|
|
86
|
|
-
|
|
87
|
|
- #region 查询条件
|
|
88
|
|
- string sqlWorkOrder = "";
|
|
89
|
|
- string sqlRegion = "";
|
|
90
|
|
-
|
|
91
|
|
- //年份参数存在
|
|
92
|
|
- if (!string.IsNullOrEmpty(years))
|
|
93
|
|
- {
|
|
94
|
|
- //season = 0;
|
|
95
|
|
- DateTime beginTime;
|
|
96
|
|
- beginTime = Convert.ToDateTime(years + "-1-01 00:00:00");
|
|
97
|
|
- sqlWorkOrder += $" AND CreateTime >='" + beginTime.ToString() + "' and CreateTime<'" + beginTime.AddYears(1).AddSeconds(-1) + "'";
|
|
98
|
|
-
|
|
99
|
|
- //季度参数存在
|
|
100
|
|
- if (season > 0)
|
|
101
|
|
- {
|
|
102
|
|
- //第一季度:1月-3月
|
|
103
|
|
- //第二季度:4月-6月
|
|
104
|
|
- //第三季度:7月-9月
|
|
105
|
|
- //第四季度:10月-12月
|
|
106
|
|
- bool isSeason = false;
|
|
107
|
|
- DateTime beginTimeSeason = DateTime.Now;
|
|
108
|
|
- if (season == 1)
|
|
109
|
|
- {
|
|
110
|
|
- isSeason = true;
|
|
111
|
|
- beginTimeSeason = Convert.ToDateTime(years + "-1-01 00:00:00");
|
|
112
|
|
- }
|
|
113
|
|
- else if (season == 2)
|
|
114
|
|
- {
|
|
115
|
|
- isSeason = true;
|
|
116
|
|
- beginTimeSeason = Convert.ToDateTime(years + "-4-01 00:00:00");
|
|
117
|
|
- }
|
|
118
|
|
- else if (season == 3)
|
|
119
|
|
- {
|
|
120
|
|
- isSeason = true;
|
|
121
|
|
- beginTimeSeason = Convert.ToDateTime(years + "-7-01 00:00:00");
|
|
122
|
|
- }
|
|
123
|
|
- else if (season == 4)
|
|
124
|
|
- {
|
|
125
|
|
- isSeason = true;
|
|
126
|
|
- beginTimeSeason = Convert.ToDateTime(years + "-10-01 00:00:00");
|
|
127
|
|
- }
|
|
128
|
|
- if (isSeason)
|
|
129
|
|
- {
|
|
130
|
|
- sqlWorkOrder += $" AND CreateTime >='" + beginTimeSeason.ToString() + "' and CreateTime<'" + beginTimeSeason.AddMonths(3).AddSeconds(-1) + "'";
|
|
131
|
|
- }
|
|
132
|
|
- }
|
|
133
|
|
- }
|
|
134
|
|
- if (areaid > 0)
|
|
135
|
|
- {
|
|
136
|
|
- sqlWorkOrder += " and IsUserSend = " + areaid + " ";
|
|
137
|
|
- sqlRegion += $" AND (SELECT F_ParentId FROM dbo.T_Cus_RegionCategory WHERE F_RegionId = c.F_ParentId) = {areaid}";
|
|
138
|
|
- }
|
|
139
|
|
- if (regionid > 0)
|
|
140
|
|
- {
|
|
141
|
|
- sqlWorkOrder += " and IsAdminSend = " + regionid + " ";
|
|
142
|
|
- sqlRegion += $" AND c.F_ParentId = {regionid}";
|
|
143
|
|
- }
|
|
144
|
|
- if (iseffective > -1)
|
|
145
|
|
- sqlWorkOrder += " and IsTimeOut = " + iseffective + " ";
|
|
146
|
|
- if (gdly>0)
|
|
147
|
|
- sqlWorkOrder += " and Type = " + Convert.ToInt32(gdly) + " ";
|
|
148
|
|
- if (stime != null && stime.Trim() != "")
|
|
149
|
|
- {
|
|
150
|
|
- sqlWorkOrder += " and CONVERT(varchar , CreateTime, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
|
|
151
|
|
- }
|
|
152
|
|
- if (endtime != null && endtime.Trim() != "")
|
|
153
|
|
- {
|
|
154
|
|
- sqlWorkOrder += " and CONVERT(varchar , CreateTime, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
|
|
155
|
|
- }
|
|
156
|
|
- #endregion
|
|
157
|
|
-
|
|
158
|
|
- //获取坐席数据
|
|
159
|
|
- DataTable dt = new DataTable();
|
|
160
|
|
- //可在添加工单时,查看投诉类型的项,目前通过表查询获取(名称不一样使用备注的字段信息)
|
|
161
|
|
- string sql = " SELECT * FROM dbo.T_Sys_Department WHERE F_ParentCode = '|0|339|' AND F_DeptId != 553 ORDER BY F_Sort ASC ";
|
|
162
|
|
- dt = DbHelperSQL.Query(sql).Tables[0];
|
|
163
|
|
- //获取工单缓存
|
|
164
|
|
- var listWo = bllWo.DataTableToList(bllWo.GetList($" IsDel=0 {sqlWorkOrder} ").Tables[0]);
|
|
165
|
|
- int yesCount = 0, notCount = 0;
|
|
166
|
|
- for (int i = 0; i < dt.Rows.Count; i++)
|
|
167
|
|
- {
|
|
168
|
|
- DataRow drNew = dtNew.NewRow();
|
|
169
|
|
- drNew["投诉类型"] = dt.Rows[i]["F_DeptName"].ToString();
|
|
170
|
|
- //State工单状态 0待指派,1待处理 2已处理 Source投诉类型(投诉部门)
|
|
171
|
|
- var listYesCount = listWo.Where(x => x.State == 2 && x.Source == dt.Rows[i]["F_DeptId"].ToString()).Count();
|
|
172
|
|
- var listNotCount = listWo.Where(x => (x.State == 0 || x.State == 1) && x.Source == dt.Rows[i]["F_DeptId"].ToString()).Count();
|
|
173
|
|
- drNew["结案"] = listYesCount.ToString();
|
|
174
|
|
- drNew["未结案"] = listNotCount.ToString();
|
|
175
|
|
- //计算结案率
|
|
176
|
|
- int totalCount = listYesCount + listNotCount;
|
|
177
|
|
- drNew["总计"] = totalCount.ToString();
|
|
178
|
|
- Double notRate = 0.00;
|
|
179
|
|
- if (totalCount > 0)
|
|
180
|
|
- notRate = (double)listYesCount / (double)totalCount;
|
|
181
|
|
- drNew["结案率"] = (notRate * 100).ToString("0.00") + "%";
|
|
182
|
|
- //统计结案,未结案数
|
|
183
|
|
- yesCount += listYesCount;
|
|
184
|
|
- notCount += listNotCount;
|
|
185
|
|
- dtNew.Rows.Add(drNew);
|
|
186
|
|
- }
|
|
187
|
|
- #region 获取一条统计信息
|
|
188
|
|
- DataRow drzj = dtNew.NewRow();
|
|
189
|
|
- drzj["投诉类型"] = "总计";
|
|
190
|
|
- drzj["结案"] = yesCount.ToString();
|
|
191
|
|
- drzj["未结案"] = notCount.ToString();
|
|
192
|
|
- //计算结案率
|
|
193
|
|
- int totalAllCount = yesCount + notCount;
|
|
194
|
|
- drzj["总计"] = totalAllCount.ToString();
|
|
195
|
|
- Double yesAllRate = 0.00;
|
|
196
|
|
- if (totalAllCount > 0)
|
|
197
|
|
- yesAllRate = (double)yesCount / (double)totalAllCount;
|
|
198
|
|
- drzj["结案率"] = (yesAllRate * 100).ToString("0.00") + "%";
|
|
199
|
|
- dtNew.Rows.Add(drzj);
|
|
200
|
|
- #endregion
|
|
201
|
|
- return dtNew;
|
|
202
|
|
- }
|
|
203
|
|
-
|
|
204
|
|
- /// <summary>
|
|
205
|
|
- /// 导出投诉类型报表excel
|
|
206
|
|
- /// </summary>
|
|
207
|
|
- /// <returns></returns>
|
|
208
|
|
- public ActionResult ExportExcel(string years, int season = 0, int areaid = 0, int regionid = 0, int stageid = 0, int iseffective = -1, int gdly = 0, string stime = "", string endtime = "")
|
|
209
|
|
- {
|
|
210
|
|
- ActionResult res = NoToken("未知错误,请重新登录");
|
|
211
|
|
- if (Request.IsAuthenticated)
|
|
212
|
|
- {
|
|
213
|
|
- //导出dtnew
|
|
214
|
|
- NPOIHelper npoi = new NPOIHelper();
|
|
215
|
|
- DataTable dt = getData(years, season, areaid, regionid, stageid, iseffective, gdly, stime, endtime);
|
|
216
|
|
- if (npoi.ExportToExcel("投诉类型数据报表", dt, null) == "")
|
|
217
|
|
- {
|
|
218
|
|
- return Success("导出成功");
|
|
219
|
|
- }
|
|
220
|
|
- else
|
|
221
|
|
- {
|
|
222
|
|
- return Error("导出失败");
|
|
223
|
|
- }
|
|
224
|
|
- }
|
|
225
|
|
- return res;
|
|
226
|
|
- }
|
|
227
|
|
- }
|
|
228
|
|
-}
|