|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+ public class GDPosController : BaseController
|
|
|
14
|
+ {
|
|
|
15
|
+ // GET: GDPos
|
|
|
16
|
+ //public ActionResult Index()
|
|
|
17
|
+ //{
|
|
|
18
|
+ // return View();
|
|
|
19
|
+ //}
|
|
|
20
|
+
|
|
|
21
|
+ /// <summary>
|
|
|
22
|
+ /// 获取工单地区报表
|
|
|
23
|
+ /// </summary>
|
|
|
24
|
+ /// <param name="stime"></param>
|
|
|
25
|
+ /// <param name="endtime"></param>
|
|
|
26
|
+ /// <returns></returns>
|
|
|
27
|
+ public ActionResult GetDataList(string stime, string endtime)
|
|
|
28
|
+ {
|
|
|
29
|
+ ActionResult res = NoToken("未知错误,请重新登录");
|
|
|
30
|
+ DataTable dtNew = new DataTable();
|
|
|
31
|
+ dtNew = getData(stime, endtime);
|
|
|
32
|
+ res = Success("获取工单地区数据成功", dtNew);
|
|
|
33
|
+
|
|
|
34
|
+ return res;
|
|
|
35
|
+ }
|
|
|
36
|
+
|
|
|
37
|
+ private DataTable getData(string stime, string endtime)
|
|
|
38
|
+ {
|
|
|
39
|
+ DataTable dtNew = new DataTable();
|
|
|
40
|
+ #region 添加表格标题
|
|
|
41
|
+ DataColumn dc = new DataColumn("省份");
|
|
|
42
|
+ dtNew.Columns.Add(dc);
|
|
|
43
|
+ var sqlGDLY = " and F_DeleteFlag=0";
|
|
|
44
|
+ var recordCount = 0;
|
|
|
45
|
+ var dtGDLY = BLL.PagerBLL.GetListPager(
|
|
|
46
|
+ "T_Sys_UserAccount",
|
|
|
47
|
+ "F_UserId",
|
|
|
48
|
+ "*",
|
|
|
49
|
+ sqlGDLY,
|
|
|
50
|
+ "ORDER BY F_Userid asc ",
|
|
|
51
|
+ 10,
|
|
|
52
|
+ 1,
|
|
|
53
|
+ true,
|
|
|
54
|
+ out recordCount);
|
|
|
55
|
+ List<Model.T_Sys_UserAccount> modelList = new BLL.T_Sys_UserAccount().DataTableToList(dtGDLY);
|
|
|
56
|
+
|
|
|
57
|
+ for (int i = 0; i < modelList.Count; i++)
|
|
|
58
|
+ {
|
|
|
59
|
+ string colname = modelList[i].F_UserCode;
|
|
|
60
|
+ dtNew.Columns.Add(new DataColumn(colname));
|
|
|
61
|
+ }
|
|
|
62
|
+ #endregion
|
|
|
63
|
+
|
|
|
64
|
+ string sqltimeCallRecords = "";
|
|
|
65
|
+ if (stime != null && stime.Trim() != "")
|
|
|
66
|
+ {
|
|
|
67
|
+ sqltimeCallRecords += " and CONVERT(varchar , CreateTime, 120)>=CONVERT(varchar , '" + stime.Trim() + " 00:00:01', 120) ";
|
|
|
68
|
+ }
|
|
|
69
|
+ if (endtime != null && endtime.Trim() != "")
|
|
|
70
|
+ {
|
|
|
71
|
+ sqltimeCallRecords += " and CONVERT(varchar , CreateTime, 120)<=CONVERT(varchar , '" + endtime.Trim() + " 23:59:59', 120) ";
|
|
|
72
|
+ }
|
|
|
73
|
+
|
|
|
74
|
+ double day = 0;
|
|
|
75
|
+ if (stime != null && endtime != null && endtime.Trim() != "" && stime.Trim() != "")
|
|
|
76
|
+ {
|
|
|
77
|
+ TimeSpan time = Convert.ToDateTime(endtime) - Convert.ToDateTime(stime);
|
|
|
78
|
+ day = time.Days + 1;
|
|
|
79
|
+ }
|
|
|
80
|
+ //获取省份数据
|
|
|
81
|
+ DataTable dt = new DataTable();
|
|
|
82
|
+ string sql = "select b.f_province from [dbo].[T_Wo_WorkOrder] a,T_Cus_CustomerBase b where a.CustomerID = b.F_CustomerId";
|
|
|
83
|
+ dt = DbHelperSQL.Query(sql).Tables[0];
|
|
|
84
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
85
|
+ {
|
|
|
86
|
+ string f_prov = "";
|
|
|
87
|
+ DataRow drNew = dtNew.NewRow();
|
|
|
88
|
+ if (dt.Rows[i][0] != null)
|
|
|
89
|
+ f_prov = dt.Rows[i][0].ToString();
|
|
|
90
|
+ drNew["省份"] = f_prov;
|
|
|
91
|
+ //获取工单来源数据
|
|
|
92
|
+ DataTable dtnew = new DataTable();
|
|
|
93
|
+ string sqlnew = "select * from T_Sys_UserAccount where 1=1 and F_DeleteFlag=0";
|
|
|
94
|
+ dtnew = DbHelperSQL.Query(sqlnew).Tables[0];
|
|
|
95
|
+ for (int j = 0; j < dtnew.Rows.Count; j++)
|
|
|
96
|
+ {
|
|
|
97
|
+ string f_ucode = "";
|
|
|
98
|
+ if (dtnew.Rows[i]["F_UserCode"] != null)
|
|
|
99
|
+ f_ucode = dt.Rows[i]["F_UserCode"].ToString();
|
|
|
100
|
+ string str = "select count(*) from [dbo].[T_Wo_WorkOrder] a,T_Cus_CustomerBase b where a.CustomerID = b.F_CustomerId and b.F_Province = '"+ f_prov + "' and a.createuser = '"+ f_ucode + "' where b.IsDel=0 " + sqltimeCallRecords;
|
|
|
101
|
+ int ecount = int.Parse(DbHelperSQL.GetSingle(str).ToString());
|
|
|
102
|
+ drNew[j + 1] = ecount.ToString();
|
|
|
103
|
+ }
|
|
|
104
|
+
|
|
|
105
|
+ dtNew.Rows.Add(drNew);
|
|
|
106
|
+ }
|
|
|
107
|
+
|
|
|
108
|
+ return dtNew;
|
|
|
109
|
+ }
|
|
|
110
|
+
|
|
|
111
|
+ /// <summary>
|
|
|
112
|
+ /// 导出excel
|
|
|
113
|
+ /// </summary>
|
|
|
114
|
+ /// <returns></returns>
|
|
|
115
|
+ public ActionResult ExportExcel(string stime, string endtime)
|
|
|
116
|
+ {
|
|
|
117
|
+ ActionResult res = NoToken("未知错误,请重新登录");
|
|
|
118
|
+ if (Request.IsAuthenticated)
|
|
|
119
|
+ {
|
|
|
120
|
+ //导出dtnew
|
|
|
121
|
+ NPOIHelper npoi = new NPOIHelper();
|
|
|
122
|
+ DataTable dt = getData(stime, endtime);
|
|
|
123
|
+ if (npoi.ExportToExcel("工单地区数据报表", dt, null) == "")
|
|
|
124
|
+ {
|
|
|
125
|
+ return Success("导出成功");
|
|
|
126
|
+ }
|
|
|
127
|
+ else
|
|
|
128
|
+ {
|
|
|
129
|
+ return Error("导出失败");
|
|
|
130
|
+ }
|
|
|
131
|
+ }
|
|
|
132
|
+ return res;
|
|
|
133
|
+ }
|
|
|
134
|
+ }
|
|
|
135
|
+}
|