Ver Código Fonte

工单修改,报表,通讯录

duhongyu 6 anos atrás
pai
commit
be052df3da

+ 3 - 3
codegit/CallCenterApi/CallCenterApi.DAL/T_Bus_WorkOrder.cs

@@ -76,7 +76,7 @@ namespace CallCenterApi.DAL
76 76
                     new SqlParameter("@F_DealResult", SqlDbType.NVarChar,-1),
77 77
                     new SqlParameter("@F_DealDes", SqlDbType.NVarChar,-1),
78 78
                     new SqlParameter("@F_DealFile", SqlDbType.VarChar,500),
79
-                    new SqlParameter("@F_DealTimely", SqlDbType.Int,4),
79
+                    new SqlParameter("@F_DealTimely", SqlDbType.VarChar,100),
80 80
                     new SqlParameter("@F_DealUser", SqlDbType.VarChar,50),
81 81
                     new SqlParameter("@F_DealTime", SqlDbType.DateTime),
82 82
                     new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
@@ -239,7 +239,7 @@ namespace CallCenterApi.DAL
239 239
                     new SqlParameter("@F_DealResult", SqlDbType.NVarChar,-1),
240 240
                     new SqlParameter("@F_DealDes", SqlDbType.NVarChar,-1),
241 241
                     new SqlParameter("@F_DealFile", SqlDbType.VarChar,500),
242
-                    new SqlParameter("@F_DealTimely", SqlDbType.Int,4),
242
+                    new SqlParameter("@F_DealTimely", SqlDbType.VarChar,100),
243 243
                     new SqlParameter("@F_DealUser", SqlDbType.VarChar,50),
244 244
                     new SqlParameter("@F_DealTime", SqlDbType.DateTime),
245 245
                     new SqlParameter("@F_CreateUser", SqlDbType.VarChar,50),
@@ -506,7 +506,7 @@ namespace CallCenterApi.DAL
506 506
                 }
507 507
                 if (row["F_DealTimely"] != null && row["F_DealTimely"].ToString() != "")
508 508
                 {
509
-                    model.F_DealTimely = int.Parse(row["F_DealTimely"].ToString());
509
+                    model.F_DealTimely = row["F_DealTimely"].ToString();
510 510
                 }
511 511
                 if (row["F_DealUser"] != null)
512 512
                 {

+ 3 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/CallCenterApi.Interface.csproj

@@ -170,6 +170,7 @@
170 170
     <Compile Include="App_Start\FilterConfig.cs" />
171 171
     <Compile Include="App_Start\ErrorAttribute.cs" />
172 172
     <Compile Include="App_Start\RouteConfig.cs" />
173
+    <Compile Include="Controllers\AddressBookController.cs" />
173 174
     <Compile Include="Controllers\AreaController.cs" />
174 175
     <Compile Include="Controllers\Base\BaseController.cs" />
175 176
     <Compile Include="Controllers\CallOutOptController.cs" />
@@ -247,6 +248,7 @@
247 248
     <Compile Include="Global.asax.cs">
248 249
       <DependentUpon>Global.asax</DependentUpon>
249 250
     </Compile>
251
+    <Compile Include="Models\Common\ButtonGroup.cs" />
250 252
     <Compile Include="Models\Common\FormsPrincipal.cs" />
251 253
     <Compile Include="Models\Common\ListBase.cs" />
252 254
     <Compile Include="Models\Dto\CallPlan.cs" />
@@ -308,6 +310,7 @@
308 310
   </ItemGroup>
309 311
   <ItemGroup>
310 312
     <Folder Include="App_Data\" />
313
+    <Folder Include="Views\AddressBook\" />
311 314
     <Folder Include="Views\Area\" />
312 315
     <Folder Include="Views\Base\" />
313 316
     <Folder Include="Views\Business\" />

+ 239 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/AddressBookController.cs

@@ -0,0 +1,239 @@
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
12
+{
13
+    public class AddressBookController : BaseController
14
+    {
15
+        private BLL.T_Cus_AddressBook bll = new BLL.T_Cus_AddressBook();
16
+        public ActionResult Add(string F_Name,string F_Sex,string F_Address, string F_Telephone,
17
+          string F_Mobile, string F_ElseMobile, string F_Position, string F_Note,int  F_Departmentid=-1,int id=0)
18
+        {
19
+            Model.T_Cus_AddressBook model = new Model.T_Cus_AddressBook();
20
+            if (string.IsNullOrEmpty(F_Name))
21
+            {
22
+                return Error("姓名不能为空");
23
+            }
24
+            if (F_Departmentid<0)
25
+            {
26
+                return Error("部门不能为空");
27
+            }
28
+            if (string.IsNullOrEmpty(F_Mobile))
29
+            {
30
+                return Error("手机号不能为空");
31
+            }
32
+            if (id == 0)
33
+            {
34
+                model.F_Name = F_Name;
35
+                model.F_Sex = F_Sex;
36
+                model.F_Address = F_Address;
37
+                model.F_Telephone = F_Telephone;
38
+                model.F_Mobile = F_Mobile;
39
+                model.F_ElseMobile = F_ElseMobile;
40
+                var deptment = new BLL.T_Sys_Department().GetModel(F_Departmentid);
41
+                 if (deptment!=null )
42
+                {
43
+                    model.F_Department = deptment.F_DeptName ;
44
+                    model.F_DepartmentId = deptment.F_DeptId  ;
45
+                }
46
+                model.F_Position = F_Position;
47
+                model.F_Note = F_Note;
48
+                int n = bll.Add(model);
49
+                if (n > 0)
50
+                {
51
+                    return Success("添加成功", n);
52
+                }
53
+                else
54
+                {
55
+                    return Error("添加失败");
56
+                }
57
+            }
58
+            else
59
+            {
60
+                model = bll.GetModel(id);
61
+                if (model != null)
62
+                {
63
+                    model.F_UserId = id;
64
+                    model.F_Name = F_Name;
65
+                    model.F_Sex = F_Sex;
66
+                    model.F_Address = F_Address;
67
+                    model.F_Telephone = F_Telephone;
68
+                    model.F_Mobile = F_Mobile;
69
+                    model.F_ElseMobile = F_ElseMobile;
70
+                    var deptment = new BLL.T_Sys_Department().GetModel(F_Departmentid);
71
+                    if (deptment != null)
72
+                    {
73
+                        model.F_Department = deptment.F_DeptName;
74
+                        model.F_DepartmentId = deptment.F_DeptId;
75
+                    }
76
+                    model.F_Position = F_Position;
77
+                    model.F_Note = F_Note;
78
+                    if (bll.Update(model))
79
+                    {
80
+                        return Success("修改成功");
81
+                    }
82
+                    else
83
+                    {
84
+                        return Error("修改失败");
85
+                    }
86
+                }
87
+                return Error("信息不存在");
88
+            }
89
+        }
90
+        /// <summary>
91
+        /// 获取一条详细信息 Id
92
+        /// </summary>
93
+        /// <param name="infoid"></param>
94
+        /// <returns></returns>
95
+        public ActionResult GetInfo(string infoid)
96
+        {
97
+            if (infoid != null && infoid.Trim() != "")
98
+            {
99
+                Model.T_Cus_AddressBook model = bll.GetModel(int.Parse(infoid.Trim()));
100
+                if (model != null)
101
+                {
102
+                    return Success("获取成功", model);
103
+                }
104
+                else
105
+                {
106
+                    return Error("获取失败");
107
+                };
108
+            }
109
+            else
110
+            {
111
+                return Error("获取参数失败");
112
+            }
113
+        }
114
+        /// <summary>
115
+        /// 删除通讯录信息
116
+        /// </summary>
117
+        /// <param name="ids"></param>
118
+        /// <returns></returns>
119
+        public ActionResult DelAddressBook(string[] ids)
120
+        {
121
+            if (ids != null && ids.Length > 0)
122
+            {
123
+                string idd = " ";
124
+                foreach (string str in ids)
125
+                {
126
+                    idd += str + ",";
127
+                }
128
+                string sql = "UPDATE dbo.T_Cus_AddressBook SET F_IsDelete = 1 WHERE F_UserId in(" + idd.TrimEnd(',') + ")";
129
+                if (!string.IsNullOrEmpty(idd.Trim()))
130
+                {
131
+                    if (DbHelperSQL.ExecuteSql(sql) > 0)
132
+                    {
133
+                        return Success("设置成功");
134
+                    }
135
+                    else
136
+                    {
137
+                        return Error("设置失败");
138
+                    }
139
+                }
140
+                else
141
+                {
142
+                    return Error("请选择用户");
143
+                }
144
+            }
145
+            else
146
+            {
147
+                return Error("获取参数失败");
148
+            }
149
+        }
150
+        public ActionResult GetList(string keywords)
151
+        {
152
+            if (Request.IsAuthenticated)
153
+            {
154
+                int userId = CurrentUser.UserData.F_UserId;
155
+                Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
156
+                int dptid = 0;
157
+                if (userModel != null)
158
+                {
159
+                        dptid = userModel.F_DeptId;
160
+                }
161
+                Model.T_Sys_Department deptModel = new BLL.T_Sys_Department().GetModel(dptid);
162
+                DataTable dt = new DataTable();
163
+                string sql = "F_IsDelete=0 ";
164
+                if (!string.IsNullOrEmpty(keywords))
165
+                {
166
+                    sql += $"  and ( F_Name like '%" + keywords.Trim() + "%'or F_Telephone like '%" + keywords.Trim() + "%'or F_Mobile like '%" + keywords.Trim() + "%'or F_ElseMobile like '%" + keywords.Trim() + "%'or F_Department like '%" + keywords.Trim() + "%' ) ";
167
+                }
168
+                if (dptid > 0)
169
+                {
170
+                        sql += " and F_DepartmentId in ( select F_DeptId from T_Sys_Department where F_DeptCode like '" + deptModel.F_DeptCode + "%') ";
171
+                }
172
+                var modelList = bll .GetModelList(sql);
173
+                var modelListOrder = modelList.OrderBy(x => x.F_Name );
174
+                return Content(modelListOrder.ToJson());
175
+            }
176
+            return NoToken("未知错误,请重新登录");
177
+        }
178
+        public ActionResult GetModelList(string keywords, int pageindex = 1, int pagesize = 10)
179
+        {
180
+            if (Request.IsAuthenticated)
181
+            {
182
+                int userId = CurrentUser.UserData.F_UserId;
183
+                Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
184
+                int dptid = 0;
185
+                if (userModel != null)
186
+                {
187
+                    dptid = userModel.F_DeptId;
188
+                }
189
+                Model.T_Sys_Department deptModel = new BLL.T_Sys_Department().GetModel(dptid);
190
+                DataTable dt = new DataTable();
191
+                string sql = "and F_IsDelete=0 ";
192
+            
193
+                if (!string.IsNullOrEmpty(keywords))
194
+                {
195
+                  sql += $"  and ( F_Name like '%" + keywords.Trim() + "%'or F_Telephone like '%" + keywords.Trim() + "%'or F_Mobile like '%" + keywords.Trim() + "%'or F_ElseMobile like '%" + keywords.Trim() + "%'or F_Department like '%" + keywords.Trim() + "%' ) ";
196
+                }
197
+                if (dptid > 0)
198
+                {
199
+                    sql += " and F_DepartmentId in ( select F_DeptId from T_Sys_Department where F_DeptCode like '" + deptModel.F_DeptCode + "%') ";
200
+                }
201
+                int recordCount = 0;
202
+                if (!string.IsNullOrWhiteSpace(sql))
203
+                {
204
+
205
+                    dt = BLL.PagerBLL.GetListPager(
206
+                        "T_Cus_AddressBook",
207
+                        "F_UserId",
208
+                        "*",
209
+                        sql,
210
+                        "ORDER BY T_Cus_AddressBook.F_UserId desc",
211
+                        pagesize,
212
+                        pageindex,
213
+                        true,
214
+                        out recordCount);
215
+                }
216
+                List<Model.T_Cus_AddressBook> modlelist = new BLL.T_Cus_AddressBook().DataTableToList(dt);
217
+                var modelListOrder = modlelist.OrderBy(x => x.F_Name);
218
+                if (modlelist.Count > 0)
219
+                {
220
+                    var obj = new
221
+                    {
222
+                        state = "success",
223
+                        message = "成功",
224
+                        rows = modelListOrder,
225
+                        total = recordCount
226
+                    };
227
+
228
+                    return Content(obj.ToJson()); ;
229
+                }
230
+                else
231
+                {
232
+
233
+                    return Success("暂无记录"); ;
234
+                }
235
+            }
236
+            return NoToken("未知错误,请重新登录");
237
+        }
238
+    }
239
+}

+ 8 - 8
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/DictionaryController.cs

@@ -32,10 +32,10 @@ namespace CallCenterApi.Interface.Controllers
32 32
                 int userId = CurrentUser.UserData.F_UserId;
33 33
                 Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
34 34
 
35
-                if (!string.IsNullOrEmpty(userModel.groupcode))
36
-                {
37
-                    sql += " and F_GroupCode = '" + userModel.groupcode + "'";
38
-                }
35
+               // if (!string.IsNullOrEmpty(userModel.groupcode))
36
+              //  {
37
+               //     sql += " and F_GroupCode = '" + userModel.groupcode + "'";
38
+               // }
39 39
 
40 40
                 var recordCount = 0;
41 41
                 var dt = BLL.PagerBLL.GetListPager(
@@ -184,10 +184,10 @@ namespace CallCenterApi.Interface.Controllers
184 184
                 int userId = CurrentUser.UserData.F_UserId;
185 185
                 Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
186 186
 
187
-                if (!string.IsNullOrEmpty(userModel.groupcode))
188
-                {
189
-                    sql += " and F_GroupCode = '" + userModel.groupcode + "'";
190
-                }
187
+               // if (!string.IsNullOrEmpty(userModel.groupcode))
188
+               // {
189
+               //     sql += " and F_GroupCode = '" + userModel.groupcode + "'";
190
+                //}
191 191
 
192 192
                 DataTable dt = new DataTable();
193 193
 

+ 3 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/customer/RegionCategoryController.cs

@@ -176,10 +176,12 @@ namespace CallCenterApi.Interface.Controllers.customer
176 176
         /// 获取地市列表
177 177
         /// </summary>
178 178
         /// <returns></returns>
179
-        public ActionResult GetCountyList(int pId = 0)
179
+        public ActionResult GetCountyList(int pId=-1)
180 180
         {
181 181
             if (Request.IsAuthenticated)
182 182
             {
183
+                if (pId < 0)
184
+                    return Success ("加载失败");
183 185
                 DataTable dt = new DataTable();
184 186
                 dt = new BLL.T_RegionCategory().GetList(" F_DeleteFlag=0 and F_ParentId=" + pId).Tables[0];
185 187
                         return Success("加载成功", dt);

+ 203 - 59
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/report/BusinessController.cs

@@ -132,30 +132,6 @@ namespace CallCenterApi.Interface.Controllers.report
132 132
 
133 133
            
134 134
         }
135
-        public class Product
136
-        {
137
-            public List<Date> dates;
138
-        }
139
-        public class Date
140
-        {
141
-            public int total;//每天总数
142
-            public string name;
143
-            public int   MonthCount1;
144
-            public string  MonthCount1name;
145
-            public string MonthCountmix1;
146
-            public int MonthCount2;
147
-            public string MonthCount2name;
148
-            public string MonthCountmix2;
149
-            public int MonthCount3;
150
-            public string MonthCount3name;
151
-            public string MonthCountmix3;
152
-            public int MonthCount4;
153
-            public string MonthCount4name;
154
-            public string MonthCountmix4;
155
-            public int MonthCount5;
156
-            public string MonthCount5name;
157
-            public string MonthCountmix5;
158
-        }
159 135
         private Date  RetuDate(string name,DateTime time ,List <Model .T_Bus_WorkOrder> modelList)
160 136
         {
161 137
             Date date = new Date() ;
@@ -163,50 +139,67 @@ namespace CallCenterApi.Interface.Controllers.report
163 139
             date.total = 0;
164 140
             date.MonthCount1 = 0;
165 141
             date.MonthCount1name = time.AddMonths(-11).Month + "-" + time.AddMonths(-4).Month + "月份日期";
166
-            date.MonthCountmix1 = "0%";
142
+            date.MonthCountmix1 = "0.00%";
167 143
             date.MonthCount2 = 0;
168 144
             date.MonthCount2name = time.AddMonths(-3).Month + "月份日期";
169
-            date.MonthCountmix2 = "0%";
145
+            date.MonthCountmix2 = "0.00%";
170 146
             date.MonthCount3 = 0;
171 147
             date.MonthCount3name = time.AddMonths(-2).Month + "月份日期";
172
-            date.MonthCountmix3 = "0%";
148
+            date.MonthCountmix3 = "0.00%";
173 149
             date.MonthCount4 = 0;
174 150
             date.MonthCount4name = time.AddMonths(-1).Month + "月份日期";
175
-            date.MonthCountmix4 = "0%";
151
+            date.MonthCountmix4 = "0.00%";
176 152
             date.MonthCount5 = 0;
177 153
             date.MonthCount5name = "不清楚日期";
178
-            date.MonthCountmix5 = "0%";
154
+            date.MonthCountmix5 = "0.00%";
179 155
             for (int j = 0; j < modelList.Count; j++)
180 156
             {
181
-                if (DateTime.Parse(modelList[j].F_CreateTime.ToString()).ToString("yyyy-MM-DD") == date.name)
182
-                    date.total++;
183
-
184
-                if (!string.IsNullOrEmpty(modelList[j].F_ProductDate))
185
-                {
186
-                    if (DateTime.Parse(modelList[j].F_ProductDate) > time.AddMonths(-11) && DateTime.Parse(modelList[j].F_ProductDate) < time.AddMonths(-3))
187
-                        date.MonthCount1++;
188
-                    if (DateTime.Parse(modelList[j].F_ProductDate) > time.AddMonths(-3) && DateTime.Parse(modelList[j].F_ProductDate) < time.AddMonths(-2))
189
-                        date.MonthCount2++;
190
-                    if (DateTime.Parse(modelList[j].F_ProductDate) > time.AddMonths(-2) && DateTime.Parse(modelList[j].F_ProductDate) < time.AddMonths(-1))
191
-                        date.MonthCount3++;
192
-                    if (DateTime.Parse(modelList[j].F_ProductDate) > time.AddMonths(-1))
193
-                        date.MonthCount4++;
194
-                }
195
-                else
157
+                string datetime = DateTime.Parse(modelList[j].F_CreateTime.ToString()).ToString("yyyy-MM-dd");
158
+                if (datetime == date.name)
196 159
                 {
197
-                    date.MonthCount5++;
160
+                    date.total++;
161
+                    if (!string.IsNullOrEmpty(modelList[j].F_ProductDate))
162
+                    {
163
+                        var pronos = DateTime.ParseExact(modelList[j].F_ProductDate, "yyyyMMdd", null).ToString("yyyy-MM-dd");
164
+                        var protime = Convert.ToDateTime(pronos);
165
+                        if (protime > time.AddMonths(-11) && protime < time.AddMonths(-3))
166
+                            date.MonthCount1++;
167
+                        if (protime > time.AddMonths(-3) && protime < time.AddMonths(-2))
168
+                            date.MonthCount2++;
169
+                        if (protime > time.AddMonths(-2) && protime < time.AddMonths(-1))
170
+                            date.MonthCount3++;
171
+                        if (protime > time.AddMonths(-1))
172
+                            date.MonthCount4++;
173
+                    }
174
+                    else
175
+                    {
176
+                        date.MonthCount5++;
177
+                    }
198 178
                 }
179
+                
199 180
             }
200 181
             if (date.total > 0)
201 182
             {
202
-                date.MonthCountmix1 = string.Format("{0:f2}%", (float)date.MonthCount1 / date.total);
203
-                date.MonthCountmix2 = string.Format("{0:f2}%", (float)date.MonthCount2 / date.total);
204
-                date.MonthCountmix3 = string.Format("{0:f2}%", (float)date.MonthCount3 / date.total);
205
-                date.MonthCountmix4 = string.Format("{0:f2}%", (float)date.MonthCount4 / date.total);
206
-                date.MonthCountmix5 = string.Format("{0:f2}%", (float)date.MonthCount5 / date.total);
183
+                date.MonthCountmix1 = string.Format("{0:f2}%", (float)date.MonthCount1 / date.total*100);
184
+                date.MonthCountmix2 = string.Format("{0:f2}%", (float)date.MonthCount2 / date.total * 100);
185
+                date.MonthCountmix3 = string.Format("{0:f2}%", (float)date.MonthCount3 / date.total * 100);
186
+                date.MonthCountmix4 = string.Format("{0:f2}%", (float)date.MonthCount4 / date.total * 100);
187
+                date.MonthCountmix5 = string.Format("{0:f2}%", (float)date.MonthCount5 / date.total * 100);
207 188
             }
208 189
             return date;
209 190
         }
191
+        public ActionResult DistributionToExcel()
192
+        {
193
+            NPOIHelper npoi = new NPOIHelper();
194
+            if (npoi.DistributionToExcel(DateTime .Now  , null) == "")
195
+            {
196
+                return Success("导出成功");
197
+            }
198
+            else
199
+            {
200
+                return Error("导出失败");
201
+            }
202
+        }
210 203
         /// <summary>
211 204
         /// 产品日期分布情况表
212 205
         /// </summary>
@@ -214,18 +207,16 @@ namespace CallCenterApi.Interface.Controllers.report
214 207
         /// <param name="edate"></param>
215 208
         /// <param name="isdc"></param>
216 209
         /// <returns></returns>
217
-        public ActionResult MarketInformation(DateTime datetime, int isdc = 0)
210
+        public ActionResult Distribution(DateTime? datetime , int isdc = 0)
218 211
         {
219
-            int userId = CurrentUser.UserData.F_UserId;
220
-            Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
212
+          //  int userId = CurrentUser.UserData.F_UserId;
213
+         //   Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
221 214
             string sql = $"  F_IsDelete=0";
222
-          
223
-         
224 215
             DateTime time=DateTime .Now ;
225 216
             DataTable dt = new DataTable();
226 217
             if (datetime != null )
227 218
             {
228
-                time = datetime;
219
+                time =DateTime .Parse ( datetime.ToString ());
229 220
             }
230 221
             int days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(time.Year, time.Month-1);//获取天数
231 222
             DateTime lastmonth= time.AddMonths(-1);
@@ -238,18 +229,171 @@ namespace CallCenterApi.Interface.Controllers.report
238 229
             #region 上月28号至最后一天
239 230
             for (int i=0;i< lastday;i ++)
240 231
             {
241
-               string  name = lastmonth.ToString("yyyy-MM") + "-" + 27 + i;
232
+               string  name = string.Format("{0}-{1}", lastmonth.ToString("yyyy-MM"), 27 + i) ;
242 233
                 product.dates.Add(RetuDate(name, time, modelList));
243 234
             }
244 235
             #endregion
245 236
             #region 本月一号至27号
246 237
             for (int i=0;i < 27; i++)
247 238
             {
248
-                string name = time .ToString("yyyy-MM") + "-"  + i;
239
+                string name = "";
240
+                if (i <9)
241
+                {
242
+                    name=  string.Format("{0}-0{1}", time.ToString("yyyy-MM"), 1 + i);
243
+                }
244
+                else
245
+                {
246
+                   name = string.Format("{0}-{1}", time.ToString("yyyy-MM"), 1 + i);
247
+                }
249 248
                 product.dates.Add(RetuDate(name, time, modelList));
250 249
             }
250
+            Date date = new Date();
251
+            date.total = modelList.Count;
252
+            date.name = "合计";
253
+            for (int j = 0; j < modelList.Count; j++)
254
+            {
255
+                if (!string.IsNullOrEmpty(modelList[j].F_ProductDate))
256
+                {
257
+                    var pronos = DateTime.ParseExact(modelList[j].F_ProductDate, "yyyyMMdd", null).ToString("yyyy-MM-dd");
258
+                    var protime = Convert.ToDateTime(pronos);
259
+                    if (protime > time.AddMonths(-11) && protime < time.AddMonths(-3))
260
+                        date.MonthCount1++;
261
+                    if (protime > time.AddMonths(-3) && protime < time.AddMonths(-2))
262
+                        date.MonthCount2++;
263
+                    if (protime > time.AddMonths(-2) && protime < time.AddMonths(-1))
264
+                        date.MonthCount3++;
265
+                    if (protime > time.AddMonths(-1))
266
+                        date.MonthCount4++;
267
+                }
268
+                else
269
+                {
270
+                    date.MonthCount5++;
271
+                }
272
+            }
273
+            if (date.total > 0)
274
+            {
275
+                date.MonthCountmix1 = string.Format("{0:f2}%", (float)date.MonthCount1 / date.total*100);
276
+                date.MonthCountmix2 = string.Format("{0:f2}%", (float)date.MonthCount2 / date.total * 100);
277
+                date.MonthCountmix3 = string.Format("{0:f2}%", (float)date.MonthCount3 / date.total * 100);
278
+                date.MonthCountmix4 = string.Format("{0:f2}%", (float)date.MonthCount4 / date.total * 100);
279
+                date.MonthCountmix5 = string.Format("{0:f2}%", (float)date.MonthCount5 / date.total * 100);
280
+            }
281
+            else
282
+            {
283
+                if (date.total > 0)
284
+                {
285
+                    date.MonthCountmix1 = "0.00%";
286
+                    date.MonthCountmix2 = "0.00%";
287
+                    date.MonthCountmix3 = "0.00%";
288
+                    date.MonthCountmix4 = "0.00%";
289
+                    date.MonthCountmix5 = "0.00%";
290
+                }
291
+            }
292
+            product.dates.Add(date);
293
+            product.factory = new List<Factory>();
294
+            var EquipmentNumber = new BLL.T_Sys_EquipmentNumber().GetModelList("F_IsDelete=0");
295
+            
296
+            if (EquipmentNumber!=null && modelList.Count>0)
297
+            {
298
+                int total = 0;
299
+                foreach (var it in EquipmentNumber)
300
+                {
301
+
302
+                    Factory factory = new Factory();
303
+                    factory.name = it.F_Production;
304
+                    factory.number = 0;
305
+                    factory.proportion = "0.00%";
306
+                    for (int i=0;i < modelList.Count;i++)
307
+                    {
308
+                        if (modelList[i].F_Manufacturer == it.F_Production)
309
+                        {
310
+                            total++;
311
+                            factory.number++;
312
+                        }
313
+                    }
314
+                    factory.proportion = string.Format("{0:f2}%", (float)factory.number / modelList.Count*100);
315
+                    product.factory.Add(factory);
316
+                }
317
+                Factory factor = new Factory();
318
+                factor.name = "合计";
319
+                factor.number = total;
320
+                factor.proportion = "0.00%";
321
+                factor.proportion = string.Format("{0:f2}%", (float)total / modelList.Count * 100);
322
+                product.factory.Add(factor);
323
+            }
324
+            var problem = new BLL.T_Sys_DictionaryValue().GetModelList("F_DictionaryFlag='WTDM'");
325
+            product.problem = new List<Factory>();
326
+            if (problem != null && modelList.Count > 0)
327
+            {
328
+                int total = 0;
329
+                foreach (var it in problem)
330
+                {
331
+                    Factory factory = new Factory();
332
+                    factory.name = it.F_Name ;
333
+                    factory.number = 0;
334
+                    factory.proportion = "0.00%";
335
+                    for (int i = 0; i < modelList.Count; i++)
336
+                    {
337
+                        if (modelList[i].F_ProblemCode == it.F_Name)
338
+                        {
339
+                            total++;
340
+                            factory.number++;
341
+                        }
342
+                    }
343
+                    factory.proportion = string.Format("{0:f2}%", (float)factory.number / modelList.Count * 100);
344
+                    product.problem.Add(factory);
345
+                }
346
+                Factory factor = new Factory();
347
+                factor.name = "合计";
348
+                factor.number = total;
349
+                factor.proportion = "0.00%";
350
+                factor.proportion = string.Format("{0:f2}%", (float)total / modelList.Count * 100);
351
+                product.problem.Add(factor);
352
+            }
353
+            var productcode = new BLL.T_Sys_DictionaryValue().GetModelList("F_DictionaryFlag='CPDM'");
354
+            product.product = new List<Factory>();
355
+            if (productcode != null && modelList.Count > 0)
356
+            {
357
+                int total = 0;
358
+                foreach (var it in productcode)
359
+                {
360
+                    Factory factory = new Factory();
361
+                    factory.name = it.F_Name;
362
+                    factory.number = 0;
363
+                    factory.proportion = "0.00%";
364
+                    for (int i = 0; i < modelList.Count; i++)
365
+                    {
366
+                        if (modelList[i].F_ProblemCode == it.F_Name)
367
+                        {
368
+                            total++;
369
+                            factory.number++;
370
+                        }
371
+                    }
372
+                    factory.proportion = string.Format("{0:f2}%", (float)factory.number / modelList.Count * 100);
373
+                    product.product.Add(factory);
374
+                }
375
+                Factory factor = new Factory();
376
+                factor.name = "合计";
377
+                factor.number = total;
378
+                factor.proportion = "0.00%";
379
+                factor.proportion = string.Format("{0:f2}%", (float)total / modelList.Count * 100);
380
+                product.product.Add(factor);
381
+            }
382
+            if (isdc > 0)
383
+            {
384
+                NPOIHelper npoi = new NPOIHelper();
385
+                if (npoi.DistributionToExcel(time, product) == "")
386
+                {
387
+                    return Success("导出成功");
388
+                }
389
+                else
390
+                {
391
+                    return Error("导出失败");
392
+                }
393
+            }
394
+            return Success("获取成功", product);
251 395
             #endregion
252
-            return null;
396
+           
253 397
         }
254 398
         /// <summary>
255 399
         /// 工单来源

+ 38 - 41
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -78,7 +78,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
78 78
         /// 获取工单列表
79 79
         /// </summary>
80 80
         /// <returns></returns>
81
-        public ActionResult GetList(string code, string cusname, string cusphone, string createby, string starttime, string endtime, string keywords, string touser, int dealTimely = 0, int see = 0, int source = 0, int type = 0, int state = -1, int pageindex = 1, int pagesize = 10)
81
+        public ActionResult GetList(string code, string starttime, string endtime,string productType,string productDate, string batchNumber,string manufacturer,string problemCode,string notifications,string keywords, string dealTimely,int area = 0,int office=0,int duplicate=-1, int see = 0, int source = 0, int type = 0, int state = -1, int pageindex = 1, int pagesize = 10)
82 82
         {
83 83
             int userId = CurrentUser.UserData.F_UserId;
84 84
             if (userId != 0)
@@ -90,10 +90,26 @@ namespace CallCenterApi.Interface.Controllers.workorder
90 90
                     sql += $" and F_Type=" + type;
91 91
                 if (source > 0)//工单来源
92 92
                     sql += $" and F_Source=" + source;
93
-                if (dealTimely > 0)
94
-                    sql += $" and F_DealTimely=" + dealTimely;
95
-                if (!string.IsNullOrWhiteSpace(touser))//参与人
96
-                    sql += $" and F_DealUser like '%" + touser.Trim() + "%'";
93
+                if (area > 0)//大区
94
+                    sql += $" and F_Area=" + area;
95
+                if (office > 0)//办事处
96
+                    sql += $" and F_Office=" + office;
97
+                if (duplicate >= 0)//办事处
98
+                    sql += $" and F_Duplicate=" + duplicate;
99
+               if (!string.IsNullOrWhiteSpace(productType))//产品代码
100
+                    sql += $" and F_ProductType = '" + productType.Trim() + "'";
101
+                if (!string.IsNullOrWhiteSpace(productDate))//生产日期
102
+                    sql += $" and F_ProductDate = '" + productDate.Trim() + "'";
103
+                if (!string.IsNullOrWhiteSpace(batchNumber))//产品编码
104
+                    sql += $" and F_BatchNumber = '" + batchNumber.Trim() + "'";
105
+                if (!string.IsNullOrWhiteSpace(manufacturer))//生产厂家
106
+                    sql += $" and F_Manufacturer = '" + manufacturer.Trim() + "'";
107
+                if (!string.IsNullOrWhiteSpace(problemCode))//问题代码
108
+                    sql += $" and F_ProblemCode = '" + problemCode.Trim() + "'";
109
+                if (!string.IsNullOrWhiteSpace(notifications))//通知人
110
+                    sql += $" and F_Notifications = '" + notifications.Trim() + "'";
111
+                if (!string.IsNullOrWhiteSpace(dealTimely))//重要级别
112
+                    sql += $" and F_DealTimely = '" + dealTimely.Trim() + "'";
97 113
                 if (!string.IsNullOrEmpty(starttime))
98 114
                     sql += " and datediff(day,F_CreateTime,'" + starttime + "')<=0 ";
99 115
                 if (!string.IsNullOrEmpty(endtime))
@@ -102,27 +118,6 @@ namespace CallCenterApi.Interface.Controllers.workorder
102 118
                     sql += $"  and ( F_CusName like '%" + keywords.Trim() + "%'or F_CusPhone like '%" + keywords.Trim() + "%' ) ";
103 119
                 if (!string.IsNullOrWhiteSpace(code))//工单编号
104 120
                     sql += $" and F_WorkOrderId like '%" + code.Trim() + "%'";
105
-                if (!string.IsNullOrWhiteSpace(createby))//创建人
106
-                {
107
-                    string F_WorkNumber = "";
108
-                    Model.T_Sys_UserAccount user = userBLL.GetModel(createby);
109
-                    if (user != null)
110
-                    {
111
-                        F_WorkNumber = user.F_UserCode;
112
-                    }
113
-                    if (!string.IsNullOrEmpty(F_WorkNumber))
114
-                    {
115
-                        sql += $"and F_CreateUser  in(" + createby + "," + F_WorkNumber + ") ";
116
-                    }
117
-                    else
118
-                    {
119
-                        sql += $"and F_CreateUser  in(" + createby + ") ";
120
-                    }
121
-                }
122
-                if (!string.IsNullOrWhiteSpace(cusname))//客户姓名
123
-                    sql += $" and F_CusName like '%" + cusname.Trim() + "%'";
124
-                if (!string.IsNullOrWhiteSpace(cusphone))//客户电话
125
-                    sql += $" and F_CusPhone like '%" + cusphone.Trim() + "%'";
126 121
                 Model.T_Sys_UserAccount ua = userBLL.GetModel(userId);
127 122
                 Model.T_Sys_RoleInfo ro = rolebll.GetModel(ua.F_RoleId);
128 123
                 string uwhere = " ";
@@ -152,16 +147,6 @@ namespace CallCenterApi.Interface.Controllers.workorder
152 147
                             if (ro.F_RoleCode == "YWY" || ro.F_RoleCode == "QTJS" || ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBTZX")
153 148
                                 return Error("无操作权限");
154 149
                             break;
155
-                        case 2://待接收
156
-                            sql += "AND F_State=2";
157
-                            sql += RetuSql(ro, see, ua);
158
-                            if (ro.F_RoleCode == "YWY")
159
-                            {
160
-                                sql += "AND F_Notifications=" + ua.F_UserCode;
161
-                            }
162
-                            if (ro.F_RoleCode == "QTJS" || ro.F_RoleCode == "JDYPTZX" || ro.F_RoleCode == "JDYBTZX")
163
-                                return Error("无操作权限");
164
-                            break;
165 150
                         case 3://待处理
166 151
                             sql += "AND F_State=3";
167 152
                             sql += RetuSql(ro, see, ua);
@@ -373,6 +358,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
373 358
             {
374 359
                 if (see != 0)
375 360
                 {
361
+                    if (HandleUser(ua)!="")
376 362
                     sql += "AND F_Largeareaid in (" + HandleUser(ua) + ")";
377 363
                 }
378 364
 
@@ -634,6 +620,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
634 620
                 }
635 621
                 else
636 622
                 {
623
+                    type = 3;
637 624
                     if (user.F_RoleId != 53)
638 625
                         return Error("请选择业务员!");
639 626
                 }
@@ -811,10 +798,15 @@ namespace CallCenterApi.Interface.Controllers.workorder
811 798
                             creatuser = it.F_CreateUser;
812 799
                             wostate = 5;
813 800
                         }
801
+                        else if (it.F_WoState == 5)
802
+                        {
803
+                            creatuser = it.F_CreateUser;
804
+                            wostate = 6;
805
+                        }
814 806
                     }
815 807
                     else
816 808
                     {
817
-                        if (it.F_WoState == 1)
809
+                        if (it.F_WoState == 1 )
818 810
                         {
819 811
                             creatuser = it.F_CreateUser;
820 812
                             wostate = 6;
@@ -881,7 +873,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
881 873
             int deptid = 0;
882 874
             if (isover == 1)
883 875
             {
884
-                model.F_DealResult = "已处理";//处理结果
876
+                
885 877
                 opt = "处理完结";
886 878
                 optbut = 10;
887 879
                 wostate = 10;
@@ -890,7 +882,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
890 882
             }
891 883
             else
892 884
             {
893
-                model.F_DealResult = "处理中";//处理结果
885
+               
894 886
                 touser = nowUser.F_UserCode;
895 887
                 deptid = nowUser.F_DeptId;
896 888
             }
@@ -913,7 +905,9 @@ namespace CallCenterApi.Interface.Controllers.workorder
913 905
                 model.F_State = wostate;
914 906
                 //处理内容
915 907
                 if (!string.IsNullOrEmpty(cont))
916
-                    model.F_DealResult += cont + ";";
908
+                    model.F_DealResult +=";" +cont ;
909
+                else
910
+                    model.F_DealResult += cont ;
917 911
                 model.F_DealTime = DateTime.Now;
918 912
                 workorderBLL.Update(model);
919 913
                 #endregion
@@ -929,7 +923,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
929 923
         /// <param name="orderid"></param>
930 924
         /// <param name="cont"></param>
931 925
         /// <returns></returns>
932
-        public ActionResult Sing(int id, int dealTimely, string reason)
926
+        public ActionResult Sing(int id, string  dealTimely, string reason)
933 927
         {
934 928
             if (Request.IsAuthenticated)
935 929
             {
@@ -1069,6 +1063,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
1069 1063
                 if (deptmodel.F_Layer == 2)
1070 1064
                 {
1071 1065
                     F_Officeid = deptmodel.F_DeptId;
1066
+                    model.F_Area = deptmodel.F_ParentId.ToString();
1067
+                    model.F_Office = deptmodel.F_DeptId.ToString();
1072 1068
                     F_Largeareaid = deptmodel.F_ParentId;
1073 1069
                 }
1074 1070
                 else if (deptmodel.F_Layer == 3)
@@ -1095,6 +1091,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1095 1091
                 model.F_Largeareaid = F_Largeareaid;//转派大区id
1096 1092
                 model.F_Officeid = F_Officeid;//转派办事处id
1097 1093
                 model.F_Distribution = F_Distribution; //转派分销组id
1094
+                model.F_DealUser = touser;//已接单待处理;//已接单待处理
1098 1095
                 workorderBLL.Update(model);
1099 1096
                 #endregion
1100 1097
                 return true;

Diferenças do arquivo suprimidas por serem muito extensas
+ 42 - 49
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkorderAppController.cs


+ 121 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Models/Common/ButtonGroup.cs

@@ -0,0 +1,121 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Web;
5
+
6
+namespace CallCenterApi.Interface.Models.Common
7
+{
8
+    public class ButtonGroup
9
+    {
10
+       
11
+    
12
+        public static button delete()
13
+        {
14
+            return new button(3, "删除");
15
+        }
16
+        public static button submit()
17
+        {
18
+            return new button(4, "提交");
19
+        }
20
+        public static button assign()
21
+        {
22
+            return new button(5, "指派");
23
+        }
24
+        public static button handle()
25
+        {
26
+            return new button(6, "处理");
27
+        }
28
+        public static button goback()
29
+        {
30
+            return new button(7, "退回");
31
+        }
32
+        public static button sign()
33
+        {
34
+            return new button(8, "标记");
35
+        }
36
+        /// <summary>
37
+        /// 按钮类
38
+        /// </summary>
39
+        public class button
40
+        {
41
+            public int key { get; set; }
42
+            public string value { get; set; }
43
+            public button(int _key, string _value)
44
+            {
45
+                key = _key;
46
+                value = _value;
47
+            }
48
+        }
49
+        /// <summary>
50
+        /// 根据状态和角色代码获取操作按钮
51
+        /// </summary>
52
+        /// <param name="state"></param>
53
+        /// <param name="code"></param>
54
+        /// <param name="iszb"></param>
55
+        /// <returns></returns>
56
+        public static List<button> GetButtons(string   state, string code)
57
+        {
58
+            List<button> buttons = new List<button>();
59
+          
60
+            switch (state)
61
+            {
62
+                case "0":
63
+                    //坐席 坐席班长 管理员
64
+                    if (code == "JDYPTZX" || code == "JDYBTZX" || code == "XTGLY")
65
+                    {
66
+                        buttons.Add(submit());
67
+                       buttons.Add(delete());
68
+                        buttons.Add(sign());
69
+                    }
70
+                    break;
71
+                case "1":
72
+                    //办事处经理
73
+                    if (code == "BSCJL" || code == "XTGLY")
74
+                    {
75
+                        buttons.Add(assign());
76
+                        buttons.Add(goback());
77
+                        buttons.Add(sign());
78
+                    }
79
+                    break;
80
+                case "3":
81
+                    //业务员
82
+                    if (code == "YWY" || code == "XTGLY")
83
+                    {
84
+                        buttons.Add(handle());
85
+                        buttons.Add(goback());
86
+                        buttons.Add(sign());
87
+                    }
88
+                    break;
89
+                case "4":
90
+                    //业务员
91
+                    if (code == "YWY" || code == "XTGLY")
92
+                    {
93
+                        buttons.Add(handle());
94
+                        buttons.Add(goback());
95
+                        buttons.Add(sign());
96
+                    }
97
+                    break;
98
+                case "5":
99
+                    //办事处经理
100
+                    if (code == "BSCJL" || code == "XTGLY")
101
+                    {
102
+                        buttons.Add(assign());
103
+                        buttons.Add(goback());
104
+                        buttons.Add(sign());
105
+                    }
106
+                    break;
107
+                case "6":
108
+                    //坐席 坐席班长 管理员
109
+                    if (code == "JDYPTZX" || code == "JDYBTZX" || code == "XTGLY")
110
+                    {
111
+                        buttons.Add(submit());
112
+                         buttons.Add(delete());
113
+                        buttons.Add(sign());
114
+                    }
115
+                    break;
116
+            }
117
+            return buttons;
118
+        }
119
+    
120
+}
121
+}

+ 1 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Models/Input/WorkOrderInput.cs

@@ -74,7 +74,7 @@ namespace CallCenterApi.Interface.Models.Input
74 74
         /// <summary>
75 75
         /// 重要级别
76 76
         /// </summary>
77
-        public int? F_DealTimely
77
+        public string  F_DealTimely
78 78
         {
79 79
             get;set;
80 80
         }

+ 2 - 2
codegit/CallCenterApi/CallCenterApi.Model/T_Bus_WorkOrder.cs

@@ -36,7 +36,7 @@ namespace CallCenterApi.Model
36 36
         private string _f_dealresult;
37 37
         private string _f_dealdes;
38 38
         private string _f_dealfile;
39
-        private int? _f_dealtimely;
39
+        private string  _f_dealtimely;
40 40
         private string _f_dealuser;
41 41
         private DateTime? _f_dealtime;
42 42
         private string _f_createuser;
@@ -404,7 +404,7 @@ namespace CallCenterApi.Model
404 404
         /// <summary>
405 405
         /// 重要级别1红色2绿色3普通
406 406
         /// </summary>
407
-        public int? F_DealTimely
407
+        public   string F_DealTimely
408 408
         {
409 409
             set { _f_dealtimely = value; }
410 410
             get { return _f_dealtimely; }

+ 34 - 0
codegit/CallCenterCommon/CallCenter.Utility/NPOI/Market.cs

@@ -15,4 +15,38 @@ namespace CallCenter.Utility
15 15
         public Ification spotcheck;//市场抽检
16 16
         public Ification other;//其他信息
17 17
     }
18
+    public class Product
19
+    {
20
+        public List<Date> dates;
21
+        public List<Factory> factory;
22
+        public List<Factory> problem;
23
+        public List<Factory> product;
24
+    }
25
+    
26
+    public class Factory
27
+    {
28
+        public string name;
29
+        public int number;
30
+        public string proportion;
31
+    }
32
+    public class Date
33
+    {
34
+        public int total;//每天总数
35
+        public string name;
36
+        public int MonthCount1;
37
+        public string MonthCount1name;
38
+        public string MonthCountmix1;
39
+        public int MonthCount2;
40
+        public string MonthCount2name;
41
+        public string MonthCountmix2;
42
+        public int MonthCount3;
43
+        public string MonthCount3name;
44
+        public string MonthCountmix3;
45
+        public int MonthCount4;
46
+        public string MonthCount4name;
47
+        public string MonthCountmix4;
48
+        public int MonthCount5;
49
+        public string MonthCount5name;
50
+        public string MonthCountmix5;
51
+    }
18 52
 }

+ 544 - 2
codegit/CallCenterCommon/CallCenter.Utility/NPOI/NPOIHelper.cs

@@ -732,6 +732,548 @@ namespace CallCenter.Utility
732 732
             }
733 733
         }
734 734
 
735
-    
736
-}
735
+        private void Columnwidth(int number, ISheet ffSheet)
736
+        {
737
+            for (int columnNum = 0; columnNum <= number; columnNum++)
738
+            {
739
+                int columnWidth = ffSheet.GetColumnWidth(columnNum) / 256;//获取当前列宽度  
740
+                for (int rowNum = 1; rowNum <= ffSheet.LastRowNum; rowNum++)//在这一列上循环行  
741
+                {
742
+                    IRow currentRow = ffSheet.GetRow(rowNum);
743
+                    ICell currentCell = currentRow.GetCell(columnNum);
744
+                    int length = Encoding.UTF8.GetBytes(currentCell.ToString()).Length;//获取当前单元格的内容宽度  
745
+                    if (columnWidth < length + 1)
746
+                    {
747
+                        columnWidth = length + 1;
748
+                    }//若当前单元格内容宽度大于列宽,则调整列宽为当前单元格宽度,后面的+1是我人为的将宽度增加一个字符  
749
+                }
750
+            }
751
+        }
752
+        /// <summary>
753
+        /// 投诉产品日期分布表
754
+        /// </summary>
755
+        /// <param name="ds"></param>
756
+        /// <returns></returns>
757
+        public string DistributionToExcel(DateTime datetime, Product product)
758
+        {
759
+            try
760
+            {
761
+                HSSFWorkbook workbook = new HSSFWorkbook();
762
+                ISheet sheet = workbook.CreateSheet("Sheet1");
763
+                ICellStyle cellStyle = workbook.CreateCellStyle();
764
+                NPOI.SS.UserModel.IFont cellfont = workbook.CreateFont();
765
+                cellfont.Boldweight = (short)FontBoldWeight.Normal;
766
+                cellStyle.SetFont(cellfont);
767
+                ICellStyle cellStylebt = workbook.CreateCellStyle();
768
+                NPOI.SS.UserModel.IFont cellfontbt = workbook.CreateFont();
769
+                cellfontbt.Boldweight = (short)FontBoldWeight.Bold;
770
+               
771
+                cellStylebt.SetFont(cellfontbt);
772
+                cellStylebt.VerticalAlignment = VerticalAlignment.Center;
773
+                cellStylebt.Alignment = HorizontalAlignment.Center;
774
+                IRow irow1 = sheet.CreateRow(0);
775
+                ICell cell1 = irow1.CreateCell(0);
776
+                cell1.SetCellValue(datetime.Year +"年"+datetime .Month +"月份投诉产品日期分布情况表");
777
+                cell1.CellStyle = cellStylebt;
778
+                sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, 13));
779
+                #region 产品投诉情况
780
+                
781
+                IRow irow2 = sheet.CreateRow(1);
782
+                ICell cell2 = irow2.CreateCell(0);
783
+                ICellStyle style13 = workbook.CreateCellStyle();
784
+                style13.BorderDiagonalLineStyle = BorderStyle.Thin;
785
+                style13.BorderDiagonal = BorderDiagonal.Backward;
786
+                style13.BorderDiagonalColor = IndexedColors.Black .Index;
787
+                StringBuilder sb = new StringBuilder();
788
+                sb.AppendLine("数量".PadLeft(15));//该行不足长度10在左侧填空格
789
+                sb.AppendLine("日期".PadRight(15));//该行不足长度10在右侧填空格
790
+                cell2.SetCellValue(sb.ToString ());
791
+                cell2.CellStyle = cellStylebt;
792
+                irow2.GetCell(0).CellStyle = style13;
793
+                sheet.AddMergedRegion(new CellRangeAddress(1, 2, 0,0 ));
794
+                ICell cell6 = irow2.CreateCell(1);
795
+                cell6.SetCellValue("投诉产品");
796
+                cell6.CellStyle = cellStylebt;
797
+                sheet.AddMergedRegion(new CellRangeAddress(1, 1, 1, 1));
798
+                for (int i=0;i<5;i ++)
799
+                {
800
+                    string msg = "";
801
+                    switch (i)
802
+                    {
803
+                        case 0:
804
+                            msg = datetime.AddMonths(-11).Month + "-" + datetime.AddMonths(-4).Month + "月份日期";
805
+                            break;
806
+                        case 1:
807
+                            msg = datetime.AddMonths(-3).Month + "月份日期";
808
+                            break;
809
+                        case 2:
810
+                            msg = datetime.AddMonths(-2).Month + "月份日期";
811
+                            break;
812
+                        case 3:
813
+                            msg = datetime.AddMonths(-1).Month + "月份日期";
814
+                            break;
815
+                        case 4:
816
+                            msg = "不清楚日期";
817
+                            break;
818
+                    }
819
+                    ICell cell3 = irow2.CreateCell(i *2+ 2 );
820
+                    cell3.SetCellValue(msg);
821
+                    cell3.CellStyle = cellStylebt;
822
+                    sheet.AddMergedRegion(new CellRangeAddress(1, 1, i * 2 + 2, i * 2 + 3));
823
+                }
824
+                 IRow irow3 = sheet.CreateRow(2);
825
+                for (int i = 0; i < 11; i++)
826
+                {
827
+
828
+                    string msg = "";
829
+                    if (i ==0)
830
+                    {
831
+                        msg = "数量";
832
+                    }
833
+                    else
834
+                    {
835
+                        if (i % 2 == 0)
836
+                        {
837
+                            msg = "占比";
838
+                        }
839
+                        else
840
+                        {
841
+                            msg = "数量";
842
+                        }
843
+                    }
844
+                    ICell cell4 = irow3.CreateCell(i+1);
845
+                    cell4.SetCellValue(msg);
846
+                    cell4.CellStyle = cellStylebt;
847
+                    
848
+                }
849
+                List<Date> dt1 = product.dates;
850
+                if (dt1!=null )
851
+                {
852
+                    for (int i=0;i < dt1.Count;i ++)
853
+                    {
854
+                        IRow irow4 = sheet.CreateRow(3 + i);
855
+                        string msg = "";
856
+                        for (int j = 0; j < 12; j ++)
857
+                        {
858
+                            switch (j )
859
+                            {
860
+                                case 0:
861
+                                    msg = dt1[i].name;
862
+                                    break;
863
+                                case 1:
864
+                                    msg = dt1[i].total.ToString();
865
+                                    break;
866
+                                case 2:
867
+                                    msg = dt1[i].MonthCount1 .ToString ();
868
+                                    break;
869
+                                case 3:
870
+                                    msg = dt1[i].MonthCountmix1 .ToString();
871
+                                    break;
872
+                                case 4:
873
+                                    msg = dt1[i].MonthCount2.ToString();
874
+                                    break;
875
+                                case 5:
876
+                                    msg = dt1[i].MonthCountmix2.ToString();
877
+                                    break;
878
+                                case 6:
879
+                                    msg = dt1[i].MonthCount3.ToString();
880
+                                    break;
881
+                                case 7:
882
+                                    msg = dt1[i].MonthCountmix3.ToString();
883
+                                    break;
884
+                                case 8:
885
+                                    msg = dt1[i].MonthCount4.ToString();
886
+                                    break;
887
+                                case 9:
888
+                                    msg = dt1[i].MonthCountmix4.ToString();
889
+                                    break;
890
+                                case 10:
891
+                                    msg = dt1[i].MonthCount5.ToString();
892
+                                    break;
893
+                                case 11:
894
+                                    msg = dt1[i].MonthCountmix5.ToString();
895
+                                    break;
896
+                                   
897
+                            }
898
+                            ICell cell5 = irow4.CreateCell(j);
899
+                            cell5.SetCellValue(msg);
900
+                            cell5.CellStyle = cellStylebt;
901
+                        }
902
+                    }
903
+                }
904
+                int t = dt1.Count + 3;int count = 0;
905
+                List<Factory> Factory1 = product.factory;
906
+                List<Factory> Factory2 = product.problem;
907
+                List<Factory> Factory3 = product.product;
908
+                int factory = 0, problem = 0, productcode = 0;
909
+                if (Factory1 != null)
910
+                    factory = (Factory1.Count / 2) + (0 == Factory1.Count % 2 ? 0 : 1);  
911
+                if (Factory2 != null)
912
+                    problem = Factory2.Count;
913
+                if (Factory3 != null)
914
+                    productcode = Factory3.Count;
915
+                bool istrue = true; int a = 0, total = problem + productcode;
916
+                if (factory>(total))
917
+                {
918
+                    count = factory;
919
+                   a = factory - total;
920
+                }
921
+                else
922
+                {
923
+                    istrue = false;
924
+                    count = total;
925
+                }
926
+                   
927
+                IRow irow5 = sheet.CreateRow(t);
928
+                ICell cell7 = irow5.CreateCell(0);
929
+                cell7.SetCellValue("工\n厂\n投\n诉\n占\n比\n");
930
+                cell7.CellStyle = cellStylebt;
931
+                sheet.AddMergedRegion(new CellRangeAddress(t, t+ count, 0, 0));
932
+                ICell cell10 = irow5.CreateCell(7);
933
+                cell10.SetCellValue("各\n质\n量\n问\n题\n占\n比\n");
934
+                cell10.CellStyle = cellStylebt;
935
+                int structure = 0;
936
+                if (istrue)
937
+                {
938
+                  if (a >1)
939
+                    {
940
+                        structure = t + problem + a / 2;
941
+                        sheet.AddMergedRegion(new CellRangeAddress(t, t + problem + a / 2, 7, 7));
942
+                    }
943
+                       
944
+                  else
945
+                    {
946
+                        structure = t + problem;
947
+                        sheet.AddMergedRegion(new CellRangeAddress(t, t + problem + 1, 7, 7));
948
+                    }
949
+                }
950
+                    else 
951
+                sheet.AddMergedRegion(new CellRangeAddress(t, t + problem, 7, 7));
952
+                IRow irow7 = sheet.CreateRow(structure);
953
+                ICell cell11 = irow7.CreateCell(7);
954
+                cell11.SetCellValue("结\n构\n占\n比\n");
955
+                cell11.CellStyle = cellStylebt;
956
+                if (istrue)
957
+                {
958
+                    if (a > 1)
959
+                        sheet.AddMergedRegion(new CellRangeAddress(t + problem + a / 2+1, t + total + 1 +a/2, 7, 7));
960
+                    else
961
+                        sheet.AddMergedRegion(new CellRangeAddress(t + problem + 2, t + total + 2, 7, 7));
962
+                }
963
+                    else
964
+                    sheet.AddMergedRegion(new CellRangeAddress(t + problem+1, t +  1 + total, 7, 7));
965
+                if (Factory1 != null)
966
+                {
967
+                    for (int i = 0; i < count; i++)
968
+                    {
969
+                        if (i ==0 || t + i== structure)
970
+                        {
971
+                            if (i < Factory1.Count )
972
+                            {
973
+                                for (int j = 0; j < 6; j++)
974
+                                {
975
+                                    string msg = "";
976
+                                    switch (j)
977
+                                    {
978
+                                        case 0:
979
+                                            msg = Factory1[i * 2].name;
980
+                                            break;
981
+                                        case 1:
982
+                                            msg = Factory1[i * 2].number.ToString();
983
+                                            break;
984
+                                        case 2:
985
+                                            msg = Factory1[i * 2].proportion;
986
+                                            break;
987
+                                        case 3:
988
+                                            msg = Factory1[i * 2 + 1].name;
989
+                                            break;
990
+                                        case 4:
991
+                                            msg = Factory1[i * 2 + 1].number.ToString();
992
+                                            break;
993
+                                        case 5:
994
+                                            msg = Factory1[i * 2 + 1].proportion;
995
+                                            break;
996
+                                    }
997
+                                    if (i == 0)
998
+                                    {
999
+                                        ICell cell8 = irow5.CreateCell(j + 1);
1000
+                                        cell8.SetCellValue(msg);
1001
+                                        cell8.CellStyle = cellStylebt;
1002
+                                    }
1003
+                                    else
1004
+                                    {
1005
+                                        ICell cell8 = irow7.CreateCell(j + 1);
1006
+                                        cell8.SetCellValue(msg);
1007
+                                        cell8.CellStyle = cellStylebt;
1008
+                                    }
1009
+
1010
+                                }
1011
+                            }
1012
+                            if (i ==0)
1013
+                            {
1014
+                                for (int z = 0; z < 3; z++)
1015
+                                {
1016
+                                    string msg = "";
1017
+                                    switch (z)
1018
+                                    {
1019
+                                        case 0:
1020
+                                            ICell cell8 = irow5.CreateCell(8);
1021
+                                            cell8.SetCellValue(Factory2[0].name );
1022
+                                            cell8.CellStyle = cellStylebt;
1023
+                                            sheet.AddMergedRegion(new CellRangeAddress(t, t , 8, 9));
1024
+                                            break;
1025
+                                        case 1:
1026
+                                            ICell cell9 = irow5.CreateCell(10);
1027
+                                            cell9.SetCellValue(Factory2[0].number .ToString ());
1028
+                                            cell9.CellStyle = cellStylebt;
1029
+                                           
1030
+                                            break;
1031
+                                        case 2:
1032
+                                            ICell cell12 = irow5.CreateCell(11);
1033
+                                            cell12.SetCellValue(Factory2[0].proportion);
1034
+                                            cell12.CellStyle = cellStylebt;
1035
+                                            break;
1036
+                                    }
1037
+                                    
1038
+                                }
1039
+                            }
1040
+                            else if (t + i  == structure)
1041
+                            {
1042
+                                for (int z = 0; z < 3; z++)
1043
+                                {
1044
+                                    string msg = "";
1045
+                                    switch (z)
1046
+                                    {
1047
+                                        case 0:
1048
+                                            ICell cell8 = irow7.CreateCell(8);
1049
+                                            cell8.SetCellValue(Factory3[1].name);
1050
+                                            cell8.CellStyle = cellStylebt;
1051
+                                            sheet.AddMergedRegion(new CellRangeAddress(structure, structure, 8, 9));
1052
+                                            break;
1053
+                                        case 1:
1054
+                                            ICell cell9 = irow7.CreateCell(10);
1055
+                                            cell9.SetCellValue(Factory3[1].number.ToString());
1056
+                                            cell9.CellStyle = cellStylebt;
1057
+
1058
+                                            break;
1059
+                                        case 2:
1060
+                                            ICell cell12 = irow7.CreateCell(11);
1061
+                                            cell12.SetCellValue(Factory3[1].proportion);
1062
+                                            cell12.CellStyle = cellStylebt;
1063
+                                            break;
1064
+                                    }
1065
+
1066
+                                }
1067
+                            }
1068
+                           
1069
+                        }
1070
+                        else
1071
+                        {
1072
+                            
1073
+                            IRow irow6 = sheet.CreateRow(t + i);
1074
+                            if (i < Factory1.Count)
1075
+                            {
1076
+                                for (int j = 0; j < 6; j++)
1077
+                                {
1078
+                                    string msg = "";
1079
+                                    switch (j)
1080
+                                    {
1081
+                                        case 0:
1082
+                                            msg = Factory1[i * 2].name;
1083
+                                            break;
1084
+                                        case 1:
1085
+                                            msg = Factory1[i * 2].number.ToString();
1086
+                                            break;
1087
+                                        case 2:
1088
+                                            msg = Factory1[i * 2].proportion;
1089
+                                            break;
1090
+                                        case 3:
1091
+                                            msg = Factory1[i * 2 + 1].name;
1092
+                                            break;
1093
+                                        case 4:
1094
+                                            msg = Factory1[i * 2 + 1].number.ToString();
1095
+                                            break;
1096
+                                        case 5:
1097
+                                            msg = Factory1[i * 2 + 1].proportion;
1098
+                                            break;
1099
+                                    }
1100
+                                    ICell cell9 = irow6.CreateCell(j + 1);
1101
+                                    cell9.SetCellValue(msg);
1102
+                                    cell9.CellStyle = cellStylebt;
1103
+                                }
1104
+                            }
1105
+                            if (istrue)
1106
+                            {
1107
+                                int b = 1;
1108
+                                if (a >1)
1109
+                                {
1110
+                                    b= (a / 2) + (0 == a % 2 ? 0 : 1);
1111
+                                }
1112
+                                if (i < Factory2.Count -1)
1113
+                                {
1114
+                                    for (int z = 0; z < 3; z++)
1115
+                                    {
1116
+                                        string msg = "";
1117
+                                        switch (z)
1118
+                                        {
1119
+                                            case 0:
1120
+                                                ICell cell8 = irow6.CreateCell(8);
1121
+                                                cell8.SetCellValue(Factory2[i].name);
1122
+                                                cell8.CellStyle = cellStylebt;
1123
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i, 8, 9));
1124
+                                                break;
1125
+                                            case 1:
1126
+                                                ICell cell9 = irow6.CreateCell(10);
1127
+                                                cell9.SetCellValue(Factory2[i].number.ToString());
1128
+                                                cell9.CellStyle = cellStylebt;
1129
+
1130
+                                                break;
1131
+                                            case 2:
1132
+                                                ICell cell12 = irow6.CreateCell(11);
1133
+                                                cell12.SetCellValue(Factory2[i].proportion);
1134
+                                                cell12.CellStyle = cellStylebt;
1135
+                                                break;
1136
+                                        }
1137
+                                    }
1138
+                                }
1139
+                               else  if (i < Factory2.Count )
1140
+                                {
1141
+                                    for (int z = 0; z < 3; z++)
1142
+                                    {
1143
+                                        string msg = "";
1144
+                                        switch (z)
1145
+                                        {
1146
+                                            case 0:
1147
+                                                ICell cell8 = irow7.CreateCell(8);
1148
+                                                cell8.SetCellValue(Factory2[i].name);
1149
+                                                cell8.CellStyle = cellStylebt;
1150
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i+b , 8, 9));
1151
+                                                break;
1152
+                                            case 1:
1153
+                                                ICell cell9 = irow7.CreateCell(10);
1154
+                                                cell9.SetCellValue(Factory2[i].number.ToString());
1155
+                                                cell9.CellStyle = cellStylebt;
1156
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i + b, 10, 10));
1157
+
1158
+                                                break;
1159
+                                            case 2:
1160
+                                                ICell cell12 = irow7.CreateCell(11);
1161
+                                                cell12.SetCellValue(Factory2[i].proportion);
1162
+                                                cell12.CellStyle = cellStylebt;
1163
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i + b, 11, 11));
1164
+                                                break;
1165
+                                        }
1166
+                                    }
1167
+                                }
1168
+                                if (i <( Factory3.Count + Factory2.Count+b -1)&& i>= Factory2.Count + b)
1169
+                                {
1170
+                                    for (int z = 0; z < 3; z++)
1171
+                                    {
1172
+                                        string msg = "";
1173
+                                        switch (z)
1174
+                                        {
1175
+                                            case 0:
1176
+                                                ICell cell8 = irow6.CreateCell(8);
1177
+                                                cell8.SetCellValue(Factory3[i- Factory2.Count -b ].name);
1178
+                                                cell8.CellStyle = cellStylebt;
1179
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i, 8, 9));
1180
+                                                break;
1181
+                                            case 1:
1182
+                                                ICell cell9 = irow6.CreateCell(10);
1183
+                                                cell9.SetCellValue(Factory3[i - Factory2.Count - b].number.ToString());
1184
+                                                cell9.CellStyle = cellStylebt;
1185
+
1186
+                                                break;
1187
+                                            case 2:
1188
+                                                ICell cell12 = irow6.CreateCell(11);
1189
+                                                cell12.SetCellValue(Factory3[i - Factory2.Count - b].proportion);
1190
+                                                cell12.CellStyle = cellStylebt;
1191
+                                                break;
1192
+                                        }
1193
+                                    }
1194
+                                }
1195
+                                else  if ( i >= Factory2.Count + b&& i < Factory2.Count + b+ Factory3.Count )
1196
+                                {
1197
+                                    for (int z = 0; z < 3; z++)
1198
+                                    {
1199
+                                        string msg = "";
1200
+                                        switch (z)
1201
+                                        {
1202
+                                            case 0:
1203
+                                                ICell cell8 = irow7.CreateCell(8);
1204
+                                                cell8.SetCellValue(Factory3[i - Factory2.Count - b].name);
1205
+                                                cell8.CellStyle = cellStylebt;
1206
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i + b, 8, 9));
1207
+                                                break;
1208
+                                            case 1:
1209
+                                                ICell cell9 = irow7.CreateCell(10);
1210
+                                                cell9.SetCellValue(Factory3[i - Factory2.Count - b].number.ToString());
1211
+                                                cell9.CellStyle = cellStylebt;
1212
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i + b, 10, 10));
1213
+
1214
+                                                break;
1215
+                                            case 2:
1216
+                                                ICell cell12 = irow7.CreateCell(11);
1217
+                                                cell12.SetCellValue(Factory3[i - Factory2.Count - b].proportion);
1218
+                                                cell12.CellStyle = cellStylebt;
1219
+                                                sheet.AddMergedRegion(new CellRangeAddress(t + i, t + i + b, 11, 11));
1220
+                                                break;
1221
+                                        }
1222
+                                    }
1223
+                                }
1224
+
1225
+                            }
1226
+                          
1227
+                        }
1228
+                    }
1229
+                }
1230
+            
1231
+
1232
+
1233
+
1234
+
1235
+                #endregion
1236
+
1237
+
1238
+
1239
+                //自适应列宽度
1240
+                for (int i = 0; i < 12; i++)
1241
+                {
1242
+                 //  sheet.AutoSizeColumn(i);
1243
+                    sheet.SetColumnWidth(i, 15 * 256);
1244
+                }
1245
+
1246
+                using (MemoryStream ms = new MemoryStream())
1247
+                {
1248
+                    workbook.Write(ms);
1249
+
1250
+                    HttpContext curContext = HttpContext.Current;
1251
+
1252
+
1253
+                    // 设置编码和附件格式
1254
+                    curContext.Response.ContentType = "application/vnd.ms-excel";
1255
+                    curContext.Response.ContentEncoding = Encoding.UTF8;
1256
+                    curContext.Response.Charset = "";
1257
+                    curContext.Response.AppendHeader("Content-Disposition",
1258
+                        "attachment;filename=" + HttpUtility.UrlEncode("投诉产品日期分布表" + ".xls", Encoding.UTF8));
1259
+
1260
+                    curContext.Response.BinaryWrite(ms.GetBuffer());
1261
+
1262
+                    workbook = null;
1263
+                    ms.Close();
1264
+                    ms.Dispose();
1265
+
1266
+                    curContext.Response.End();
1267
+                }
1268
+                return "";
1269
+            }
1270
+            catch
1271
+            {
1272
+              return "导出失败!";
1273
+              
1274
+            }
1275
+        }
1276
+
1277
+
1278
+    }
737 1279
 }