Browse Source

售后app进度表,图片导出excel

duhongyu 5 years ago
parent
commit
95e1052f6b

+ 9 - 0
codegit/CallCenterApi/CallCenterApi.BLL/T_Bus_WorkOrder.cs

@@ -112,6 +112,15 @@ namespace CallCenterApi.BLL
112 112
             return dal.GetListTSExpt(strWhere);
113 113
         }
114 114
         /// <summary>
115
+        ///工单导出
116
+        /// </summary>
117
+        /// <param name="strWhere"></param>
118
+        /// <returns></returns>
119
+        public DataSet GetListTPExpt(string strWhere)
120
+        {
121
+            return dal.GetListTPExpt(strWhere);
122
+        }
123
+        /// <summary>
115 124
         /// 获得数据列表
116 125
         /// </summary>
117 126
         public List<CallCenterApi.Model.T_Bus_WorkOrder> DataTableToList(DataTable dt)

File diff suppressed because it is too large
+ 17 - 2
codegit/CallCenterApi/CallCenterApi.DAL/T_Bus_WorkOrder.cs


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

@@ -553,6 +553,7 @@ namespace CallCenterApi.Interface.Controllers
553 553
                 List<Model.T_Cus_AddressBook> modlelist = new BLL.T_Cus_AddressBook().DataTableToList(dt);
554 554
                 List<AddressBook> Input = AddressBooks(modlelist);
555 555
                 var modelListOrder = Input.OrderBy(x => x.F_Name);
556
+              
556 557
                 if (modlelist.Count > 0)
557 558
                 {
558 559
                     var obj = new

+ 7 - 3
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/DepartmentController.cs

@@ -58,13 +58,17 @@ namespace CallCenterApi.Interface.Controllers
58 58
         /// 获取大区列表
59 59
         /// </summary>
60 60
         /// <returns></returns>
61
-        public ActionResult GetCusAreaList(int pId = 1,int F_Layer=1)
61
+        public ActionResult GetCusAreaList(string keyword, int pId = 1,int F_Layer=1)
62 62
         {
63 63
             if (Request.IsAuthenticated)
64 64
             {
65 65
                 DataTable dt = new DataTable();
66
-                string where = " ";
67
-                    where = "isnull(F_ParentId, 1) = '" + pId + "' and F_State = 1 and F_Layer = "+ F_Layer;
66
+                string where = "isnull(F_ParentId, 1) = '" + pId + "' ";
67
+               if (!string .IsNullOrEmpty (keyword))
68
+                {
69
+                    where += "and  F_DeptName like '%" + keyword.Trim () + "%'";
70
+                }
71
+               where += " and F_State = 1 and F_Layer = "+ F_Layer;
68 72
                 dt = new BLL.T_Sys_Department().GetList(0, where, " F_Sort asc").Tables[0];
69 73
                 return Success("加载成功", dt);
70 74
             }

+ 14 - 8
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/UserAccountController.cs

@@ -272,16 +272,19 @@ namespace CallCenterApi.Interface.Controllers
272 272
                         sql += " and F_DeptId in ( select F_DeptId from T_Sys_Department where F_DeptCode like '%" + deptModel.F_DeptCode + "%') ";
273 273
                     }
274 274
                 }
275
-               
275
+
276
+                string sth = "F_UserId desc";
276 277
                 if (filter.type == 1)
277 278
                 {
278
-                    sql += "and F_RoleId=52";
279
+                    sql += "and F_RoleId in (52,49)";
279 280
                     sql += "and F_DeleteFlag=0";
281
+                    sth = "F_RoleId asc";
280 282
                 }
281 283
                 if (filter.type == 2)
282 284
                 {
283
-                    sql += "and F_See=3";
285
+                    sql += "and (F_See=3 or F_RoleId=49) ";
284 286
                     sql += "and F_DeleteFlag=0";
287
+                    sth = "F_RoleId asc";
285 288
                 }
286 289
                 sql += "and (F_See!='5' or  F_See is null)";
287 290
                 int recordCount = 0;
@@ -290,7 +293,7 @@ namespace CallCenterApi.Interface.Controllers
290 293
                                         "F_UserId",
291 294
                                         "*",
292 295
                                         sql,
293
-                                        "ORDER BY F_UserId desc",
296
+                                        "ORDER BY "+ sth,
294 297
                                         filter.PageSize,
295 298
                                         filter.PageIndex,
296 299
                                         true,
@@ -393,25 +396,28 @@ namespace CallCenterApi.Interface.Controllers
393 396
                     string str = string.Format(" and (F_UserCode like '%{0}%' or F_UserName like '%{1}%')", filter.Key, filter.Key);
394 397
                     sql += str;
395 398
                 }
399
+                string sth = "F_UserId desc";
396 400
                 if (filter .type ==1)
397 401
                 {
398
-                    sql += "and F_RoleId=52";
402
+                    sql += "and F_RoleId in (52,49)";
399 403
                     sql += "and F_DeleteFlag=0";
404
+                    sth = "F_RoleId asc";
400 405
                 }
401 406
                 if (filter.type == 2)
402 407
                 {
403
-                    sql += "and F_See=3";
408
+                    sql += "and (F_See=3 or F_RoleId=49) ";
404 409
                     sql += "and F_DeleteFlag=0";
410
+                    sth = "F_RoleId asc";
405 411
                 }
406 412
                 sql += "and (F_See!='5' or  F_See is null)";
407
-               
413
+              
408 414
                 int recordCount = 0;
409 415
                 dt = BLL.PagerBLL.GetListPager(
410 416
                                         "T_Sys_UserAccount",
411 417
                                         "F_UserId",
412 418
                                         "*",
413 419
                                         sql,
414
-                                        "ORDER BY F_UserId desc",
420
+                                        "ORDER BY "+ sth + " ",
415 421
                                         filter.PageSize,
416 422
                                         filter.PageIndex,
417 423
                                         true,

+ 86 - 27
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/report/BusinessController.cs

@@ -120,24 +120,28 @@ namespace CallCenterApi.Interface.Controllers.report
120 120
 
121 121
                     complaint.assignmentnumber= group.Where(p => p.F_State  ==1 || p.F_State == 5).Count ();//待分派
122 122
                     complaints.assignmentnumber += complaint.assignmentnumber;
123
-                    float a = 0;int c = 0;
123
+                    float a = 0;int c = 0;int assignment=0;
124 124
                     for (DateTime dt = strattime; dt <= enddatetime; dt = dt.AddDays (1))
125 125
                       {
126
-                        c++;
127
-
128
-                      var daycount= group.Where(p => (p.F_TobeallocatedTime< dt.AddDays (1)&&( p .F_AssignmenttIime>= dt || p.F_AssignmenttIime==null) )
129
-                            ).Count();
130
-
131
-                        var today= group.Where(p => p.F_AssignmenttIime >= dt && p.F_AssignmenttIime < dt.AddDays(1)
126
+                        // c++;
127
+                        assignment += group.Where(p => (p.F_TobeallocatedTime < dt.AddDays(1) && p.F_TobeallocatedTime >= dt
128
+                         && p.F_TransferTime < dt.AddDays(1) && p.F_TransferTime >= dt
129
+                               )
132 130
                             ).Count();
133
-
134
-                        if (daycount > 0)
135
-                            a += today / daycount;//当日分派率
136
-                        else
137
-                            a += 1;
138
-                      }
139
-                    complaint.assignmentrate = string.Format("{0:f2}%", a / c * 100);
140
-                    Distributionrate += a / c;
131
+                  
132
+                        //    var daycount= group.Where(p => (p.F_TransferTime < dt.AddDays (1)&&( p .F_TransferTime >= dt || p.F_AssignmenttIime==null) )
133
+                        //    ).Count();
134
+                        //
135
+                        //   var today= group.Where(p => p.F_TransferTime >= dt && p.F_TransferTime < dt.AddDays(1)
136
+                        //   ).Count();
137
+
138
+                        //  if (daycount > 0)
139
+                        //  a += (float)today / daycount;//当日分派率
140
+                        //   else
141
+                        //   a += 1;
142
+                    }
143
+                    complaint.assignmentrate = string.Format("{0:f2}%",(float ) assignment / complaint.complaintnumber * 100);
144
+                    Distributionrate += assignment;
141 145
                     complaint.pendingnumber = group.Where(p => p.F_State == 3).Count();//待处理
142 146
                     complaints.pendingnumber += complaint.pendingnumber;
143 147
                     complaint.processingnumber = group.Where(p => p.F_State == 4).Count();//处理中
@@ -194,8 +198,8 @@ namespace CallCenterApi.Interface.Controllers.report
194 198
                     complaintlist.Add(complaint);
195 199
                 }
196 200
                 complaints.complaintnumber = workoeder.Count();
197
-                if (Area.Count>0)
198
-                complaints.assignmentrate = string.Format("{0:f2}%", Distributionrate / Area.Count  * 100); //当日分派率
201
+                if (workoeder.Count() > 0)
202
+                complaints.assignmentrate = string.Format("{0:f2}%", Distributionrate / workoeder.Count() * 100); //当日分派率
199 203
                 else
200 204
                     complaints.assignmentrate = "100%";
201 205
                 if (complaints.complaintnumber > 0)
@@ -273,6 +277,9 @@ namespace CallCenterApi.Interface.Controllers.report
273 277
             string maxarea = "", minarea = "";
274 278
             Aftersale complaints = new Aftersale();
275 279
             complaints.serialnumbe = "合计";
280
+            complaints.receiving = 0;
281
+            complaints.assignmentnumber = 0;
282
+          //  float Distributionrate = 0; float Receiving = 0;
276 283
             complaints.area = "";
277 284
             if (workoeder != null)
278 285
             {
@@ -284,17 +291,66 @@ namespace CallCenterApi.Interface.Controllers.report
284 291
                     var group = workoeder.Where(p => p.F_Area == Area[i].F_DeptId.ToString());//投诉总量
285 292
                     aftersale.total = group.Count();
286 293
 
287
-                    aftersale.assignmentnumber = group.Where(p => p.F_State == 3 || p.F_State == 4 || p.F_State == 10).Count();//分派投诉
294
+                 
295
+                  
296
+                    float a = 0; float b = 0; int assignment=0, receivingorders=0;
297
+                    for (DateTime dt = strattime; dt <= enddatetime; dt = dt.AddDays(1))
298
+                    {
299
+                     //   c++;
300
+                     //   var daycount = group.Where(p => (p.F_TobeallocatedTime < dt.AddDays(1) && (p.F_TransferTime >= dt || p.F_TransferTime == null))
301
+                           //   ).Count();
302
+
303
+                      //  var jiedancount = group.Where(p => ((p.F_TransferTime < dt.AddDays(1) && p.F_Receiving >= dt) ||(p.F_TransferTime < dt.AddDays(1)&& p.F_Receiving == null))
304
+                         //    ).Count();
305
+
306
+
307
+                         assignment+= group.Where(p => (p.F_TobeallocatedTime < dt.AddDays(1) && p.F_TobeallocatedTime >= dt
308
+                         && p.F_TransferTime < dt.AddDays(1) && p.F_TransferTime >= dt
309
+                               )
310
+                             ).Count();
311
+                        receivingorders += group.Where(p => (p.F_TransferTime < dt.AddDays(1) && p.F_TransferTime >= dt
312
+                 && p.F_Receiving < dt.AddDays(1) && p.F_Receiving >= dt
313
+                       )
314
+                    ).Count();
315
+
316
+                      //  var tojiedan = group.Where(p => p.F_Receiving >= dt && p.F_Receiving < dt.AddDays(1)
317
+                     //   ).Count();
318
+                      //  var today = group.Where(p => p.F_TransferTime >= dt && p.F_TransferTime < dt.AddDays(1)
319
+                          //  ).Count();
320
+
321
+                     //   if (jiedancount > 0)
322
+                         //   b +=(float ) tojiedan / jiedancount;//当日
323
+                     //   else
324
+                          //  b += 1;
325
+
326
+
327
+                    //    if (daycount > 0)
328
+                         //   a += (float)today / daycount;//当日
329
+                     //   else
330
+                          //  a += 1;
331
+                    }
332
+                    complaints.receiving += receivingorders;//接单条数
333
+                    aftersale.receiving = receivingorders;//接单条数
334
+                    complaints.assignmentnumber += assignment;
335
+                    aftersale.assignmentnumber = assignment;//分派投诉
288 336
                     if (aftersale.total > 0)
289
-                        aftersale.assignmentrate = string.Format("{0:f2}%",(float )aftersale.assignmentnumber / aftersale.total * 100);//分派率
337
+                        aftersale.assignmentrate = string.Format("{0:f2}%", (float)assignment / aftersale.total * 100);
290 338
                     else
291 339
                         aftersale.assignmentrate = "100%";
292
-
293
-                    aftersale.receiving = group.Where(p => p.F_State == 4 || p.F_State == 10 ).Count();//接单条数
340
+                    //分派率
341
+                    // Distributionrate += (float)assignment / c;
342
+                    //   Receiving += (float)receivingorders / c;
294 343
                     if (aftersale.total > 0)
295
-                        aftersale.receivingrate = string.Format("{0:f2}%", (float)aftersale.receiving / aftersale.total * 100);//接单率
344
+                        aftersale.receivingrate = string.Format("{0:f2}%", (float)receivingorders / aftersale.total * 100);//接单率
296 345
                     else
297 346
                         aftersale.receivingrate = "100%";
347
+
348
+
349
+
350
+
351
+
352
+
353
+
298 354
                     aftersale.processingnumber = group.Where( p => p.F_State == 4).Count();//处理中投诉
299 355
                     aftersale.processednumber = group.Where( p => p.F_State == 10).Count();//已处理投诉
300 356
                     float d = 0;
@@ -340,17 +396,20 @@ namespace CallCenterApi.Interface.Controllers.report
340 396
                     aftersalelist.Add(aftersale);
341 397
                 }
342 398
                 complaints.total = workoeder.Count();
343
-                complaints.assignmentnumber = workoeder.Where(p => p.F_State == 3 || p.F_State == 4 || p.F_State == 10).Count();//分派投诉
399
+              
344 400
                 if (complaints.total > 0)
345
-                    complaints.assignmentrate = string.Format("{0:f2}%", (float)complaints.assignmentnumber / complaints.total * 100);//分派率
401
+                    complaints.assignmentrate = string.Format("{0:f2}%",(float ) complaints.assignmentnumber / complaints.total * 100); //当日分派率
346 402
                 else
347 403
                     complaints.assignmentrate = "100%";
348 404
 
349
-                complaints.receiving = workoeder.Where(p => p.F_State == 4 || p.F_State == 10).Count();//接单条数
350 405
                 if (complaints.total > 0)
351
-                    complaints.receivingrate = string.Format("{0:f2}%", (float)complaints.receiving / complaints.total * 100);//接单
406
+                    complaints.receivingrate = string.Format("{0:f2}%", (float)complaints.receiving / complaints.total * 100); //当日分派
352 407
                 else
353 408
                     complaints.receivingrate = "100%";
409
+
410
+
411
+               
412
+              
354 413
                 complaints.processingnumber = workoeder.Where(p => p.F_State == 4).Count();//处理中投诉
355 414
                 complaints.processednumber = workoeder.Where(p => p.F_State == 10).Count();//已处理投诉
356 415
                 if (complaints.total > 0)
@@ -402,7 +461,7 @@ namespace CallCenterApi.Interface.Controllers.report
402 461
             }
403 462
 
404 463
         }
405
-
464
+       
406 465
         /// <summary>
407 466
         /// 
408 467
         /// </summary>

File diff suppressed because it is too large
+ 23 - 16
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs


+ 10 - 6
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkorderAppController.cs

@@ -826,7 +826,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
826 826
             string[] ccc = {
827 827
                    "工单编号","大区","办事处","投诉时间","序号","姓名","地址","联系电话","产品代码",
828 828
                   "产品名称","规格","生产日期","产品编码","生产厂家","问题代码","质量问题","通知人"
829
-                  ,"接听人" ,"落实情况","处理进度","工单类别","分派时间","接单时间","处理时间"
829
+                  ,"接听人" ,"落实情况","处理进度","工单类别","分派时间","接单时间","处理时间","备注"
830 830
             };
831 831
             return ccc;
832 832
         }
@@ -1360,13 +1360,15 @@ namespace CallCenterApi.Interface.Controllers.workorder
1360 1360
             var user = userBLL.GetModel(clid);
1361 1361
             if (type ==1)
1362 1362
             {
1363
-                if (user.F_RoleId != 52)
1363
+                if (user.F_RoleId != 52 && user.F_RoleId != 49)
1364 1364
                     return Error("请选择办事处经理!");
1365
-            }
1365
+                if (user.F_RoleId == 49)
1366
+                        type = 3;
1367
+                }
1366 1368
             else
1367 1369
             {
1368 1370
                     type  = 3;
1369
-                    if (user.F_See != "3")
1371
+                    if (user.F_See != "3" && user.F_RoleId != 49)
1370 1372
                         return Error("请选择业务员!");
1371 1373
             }
1372 1374
             var model = workorderBLL.GetModel(id);
@@ -1734,7 +1736,8 @@ namespace CallCenterApi.Interface.Controllers.workorder
1734 1736
                 model.F_State = wostate;
1735 1737
                 if (wostate == 5)
1736 1738
                 {
1737
-                    model.F_TobeallocatedTime = DateTime.Now;
1739
+                    if (model.F_TobeallocatedTime == null)
1740
+                        model.F_TobeallocatedTime = DateTime.Now;
1738 1741
                 }
1739 1742
                 if (!string .IsNullOrEmpty (model .F_Returnnote))
1740 1743
                 model.F_Returnnote +=","+ cont;
@@ -1874,7 +1877,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1874 1877
             var optcont = "";
1875 1878
             if (!string.IsNullOrEmpty(cont))
1876 1879
                 optcont = ",说明:" + cont;
1877
-            var content = deptname + nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + opt + "工单给 " + tousername + optcont;
1880
+            var content = nowUser.F_UserName + "(" + nowUser.F_UserCode + ")" + opt + "工单给 " + deptname + tousername + optcont;
1878 1881
             var itemid = AddLog(model.F_Id , wostate, content, 1, optbut, touser, deptid, nowUser);
1879 1882
             if (itemid > 0)
1880 1883
             {
@@ -1889,6 +1892,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1889 1892
                 model.F_Distribution = F_Distribution; //转派分销组id
1890 1893
                 if (wostate == 1)
1891 1894
                 {
1895
+                    if (model.F_TobeallocatedTime==null )
1892 1896
                     model.F_TobeallocatedTime = DateTime.Now; //待分派时间
1893 1897
                 }
1894 1898
                 else

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

@@ -102,6 +102,7 @@ namespace CallCenterApi.Interface.Models.Common
102 102
                     }
103 103
                     else if (code == "CLZY")
104 104
                     {
105
+                        buttons.Add(handle());
105 106
                         buttons.Add(Remin());
106 107
                       
107 108
                     }

+ 184 - 8
codegit/CallCenterCommon/CallCenter.Utility/NPOI/NPOIHelper.cs

@@ -8,9 +8,12 @@ using NPOI.HSSF.UserModel;
8 8
 using NPOI.SS.UserModel;
9 9
 using NPOI.SS.Util;
10 10
 using NPOI.XSSF.UserModel;
11
-using CallCenterApi.DB;
12 11
 using System.Collections.Generic;
13 12
 using System.Linq;
13
+using CallCenterApi.DB;
14
+using System.Threading.Tasks;
15
+using System.Net.Http;
16
+using System.Net;
14 17
 
15 18
 namespace CallCenter.Utility
16 19
 {
@@ -1806,15 +1809,9 @@ namespace CallCenter.Utility
1806 1809
                                 cell14.SetCellValue(complaints[i].name);
1807 1810
                                 cell14.CellStyle = cellStylebt;
1808 1811
                                 break;
1809
-
1810 1812
                         }
1811
-
1812 1813
                     }
1813
-
1814
-
1815
-
1816 1814
                 }
1817
-
1818 1815
                 //自适应列宽度
1819 1816
                 for (int i = 0; i < 10; i++)
1820 1817
                 {
@@ -1853,5 +1850,184 @@ namespace CallCenter.Utility
1853 1850
         }
1854 1851
 
1855 1852
 
1856
-    }
1853
+        /// <summary>
1854
+        /// NPOI导出EXCEL
1855
+        /// </summary>
1856
+        /// <param name="dt">数据源</param>
1857
+        /// <param name="title">导出文件的名称</param>
1858
+        /// <param name="array">列宽数组</param>
1859
+        public string NpoiExcel(DataTable table,string F_ParamValue)
1860
+        {
1861
+         try {
1862
+               
1863
+                NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
1864
+            NPOI.SS.UserModel.ISheet sheet = book.CreateSheet("Sheet1");
1865
+
1866
+            NPOI.SS.UserModel.IRow headerrow = sheet.CreateRow(0);
1867
+            headerrow.Height = 30 * 20;
1868
+            ICellStyle style = book.CreateCellStyle();
1869
+            style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
1870
+            style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
1871
+            style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
1872
+            style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
1873
+            style.WrapText = true;
1874
+            style.Alignment = HorizontalAlignment.Center;
1875
+            style.VerticalAlignment = VerticalAlignment.Center;
1876
+
1877
+            List<Workorderpicture> workorderpictures = new List<Workorderpicture>();
1878
+            foreach (DataRow dr in table.Rows)
1879
+            {
1880
+                Workorderpicture workorderpicture = new Workorderpicture();
1881
+                    workorderpicture.picture = new List<string>();
1882
+               var  FileUrl = GetFileData(dr["F_DealFile"].ToString (), F_ParamValue);
1883
+                workorderpicture.workorder = dr["F_WorkOrderId"].ToString();
1884
+                foreach (var  dt in FileUrl  )
1885
+                {
1886
+                    workorderpicture.picture.Add(dt);
1887
+                }
1888
+                workorderpictures.Add(workorderpicture);
1889
+            }
1890
+            var count = workorderpictures.Select(x => x.picture.Count).Max();
1891
+                //建立内容行
1892
+                int iRowIndex = 0;
1893
+                 foreach (var it in workorderpictures)
1894
+                {
1895
+                    int iCellIndex = 0;
1896
+                    IRow irow = sheet.CreateRow(iRowIndex );
1897
+                    for (int i = 0; i < count; i++)
1898
+                    {
1899
+                        string strsj = string.Empty;
1900
+                        if (iCellIndex == 0)
1901
+                        {
1902
+                            ICell cell = irow.CreateCell(iCellIndex);
1903
+                            cell.SetCellValue(it.workorder);
1904
+                            cell.CellStyle = style;
1905
+                            iCellIndex++;
1906
+                        }
1907
+                        else
1908
+                        {
1909
+                            if (it .picture .Count <= count)
1910
+                            {
1911
+                               
1912
+                                ICell cell = irow.CreateCell(iCellIndex);
1913
+                                //  cell.SetCellValue(it.workorder);
1914
+                                if (iCellIndex<= it.picture.Count)
1915
+                                {
1916
+                                 bool n=   AddPieChartAsync(book, sheet, it.picture[iCellIndex - 1], iRowIndex, iCellIndex, 1000);
1917
+                                    if (!n )
1918
+                                        cell.SetCellValue("图片不存在!");
1919
+                                }
1920
+                                else
1921
+                                    cell.SetCellValue("");
1922
+                                cell.CellStyle = style;
1923
+                                iCellIndex++;
1924
+
1925
+                            }
1926
+                        }
1927
+                       
1928
+                    }
1929
+                    iRowIndex++;
1930
+
1931
+                }
1932
+
1933
+              
1934
+                //自适应列宽度
1935
+                for (int i = 0; i < count; i++)
1936
+                {
1937
+                    sheet.AutoSizeColumn(800);
1938
+                }
1939
+
1940
+                using (MemoryStream ms = new MemoryStream())
1941
+                {
1942
+                    book.Write(ms);
1943
+
1944
+                    HttpContext curContext = HttpContext.Current;
1945
+
1946
+
1947
+                    // 设置编码和附件格式
1948
+                    curContext.Response.ContentType = "application/vnd.ms-excel";
1949
+                    curContext.Response.ContentEncoding = Encoding.UTF8;
1950
+                    curContext.Response.Charset = "";
1951
+                    curContext.Response.AppendHeader("Content-Disposition",
1952
+                        "attachment;filename=" + HttpUtility.UrlEncode("工单列表" + ".xls", Encoding.UTF8));
1953
+
1954
+                    curContext.Response.BinaryWrite(ms.GetBuffer());
1955
+
1956
+                    book = null;
1957
+                    ms.Close();
1958
+                    ms.Dispose();
1959
+
1960
+                    curContext.Response.End();
1961
+                }
1962
+
1963
+                return "";
1964
+            }
1965
+            catch (Exception e)
1966
+            {
1967
+                return "导出失败!" + e.Message;
1968
+            }
1969
+        }
1970
+        public class Workorderpicture
1971
+        {
1972
+            public string workorder;
1973
+            public List<string> picture;
1974
+        }
1975
+        public List<string> GetFileData(string ids, string prefix)
1976
+        {
1977
+            List<string> F_Url = new List<string>();
1978
+            DataTable dt = new DataTable();
1979
+            if (!string.IsNullOrEmpty(ids))
1980
+            {
1981
+                dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_Id in (" + ids + ")").Tables[0];
1982
+                foreach (DataRow dr in dt.Rows)
1983
+                {
1984
+                    string  Url = prefix + dr["F_Url"].ToString();
1985
+                    F_Url.Add(Url);
1986
+                }
1987
+            }
1988
+            return F_Url;
1989
+        }
1990
+        /// <summary>
1991
+        /// 向sheet插入图片
1992
+        /// </summary>
1993
+        /// <param name="workbook">工作辅</param>
1994
+        /// <param name="sheet">sheet页</param>
1995
+        /// <param name="fileurl">图片地址</param>
1996
+        /// <param name="row">当前行</param>
1997
+        /// <param name="col">当前列</param>
1998
+        /// <param name="RowHeight">行高</param> 
1999
+        public bool     AddPieChartAsync(HSSFWorkbook workbook, ISheet sheet, string fileurl, int row, int col, short RowHeight)
2000
+        {
2001
+            WebClient myWebClient = new WebClient();
2002
+            myWebClient.Credentials = CredentialCache.DefaultCredentials;
2003
+            myWebClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
2004
+            try
2005
+            {
2006
+                byte[] bytes = myWebClient.DownloadData(fileurl);
2007
+                if (bytes != null)
2008
+                {
2009
+                    int pictureIdx = workbook.AddPicture(bytes, NPOI.SS.UserModel.PictureType.JPEG);
2010
+                    HSSFPatriarch patriarch = (HSSFPatriarch)sheet.CreateDrawingPatriarch();
2011
+                    HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 20, 20, col, row, col + 1, row + 1);
2012
+                    //##处理照片位置,【图片左上角为(col, row)第row+1行col+1列,右下角为( col +1, row +1)第 col +1+1行row +1+1列,宽为100,高为50
2013
+
2014
+                    HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);
2015
+                    var index = sheet.GetRow(row) ?? sheet.CreateRow(row);
2016
+                    index.Height = RowHeight;
2017
+                    //pict.Resize(0);//这句话一定不要,这是用图片原始大小来显示
2018
+                    
2019
+                }
2020
+                return true;
2021
+            }
2022
+            catch
2023
+            {
2024
+                return false ;
2025
+            }
2026
+          
2027
+           
2028
+           
2029
+        }
2030
+
2031
+
2032
+}
1857 2033
 }