查询列表时参数有限制提示The server supports a maximum of 2100 parameters.

发布时间 2023-11-06 15:02:50作者: 蒙蒙浮霁月
 1  public ActionResult Export(SAPPRItemSearchVM searchvm)
 2         {
 3             searchvm.SetFilter(MyPRItemReader, this.GetWorkingUser(true));
 4 
 5             IList<SAPPRItemDTO> list = MyPRItemReader.GetDtoList<SAPPRItemDTO>(null, MyPRItemReader.Filter.Where, "").Where(x=>x.Show).ToList();
 6             IList<SAPPRItemDTO> resultList = new List<SAPPRItemDTO>();
 7 
 8             for (int i = 0; i < list.Count; i++)
 9             {
10                 string a2 = list[i].PRNo;
11                 //询价中
12                 if (list[i].Status == PRItemStatusEnum.InQRProcess)
13                 {
14                     resultList.Add(list[i]);
15                 }
16                 ////协议 批量处理方式
17                 //else if (list[i].BatchProcessMethod == PRItemBatchProcessMethodEnum.BatchAgreement)
18                 //{
19 
20                 //    ESC.Domain.DomainModel.QR.QR a = MyQRReader.Get(list[i].QRId);
21                 //    string[] partList = a.Items.Select(x => x.Part.PartNo).Distinct().ToArray();
22                 //    IList<Quotation> quotation = new List<Quotation>();
23 
24                 //    quotation = MyQuotationReader.GetNotAgreementEffectiveQuotation(partList, list[i].RequestedDate).List();
25                 //    //quotationList = quotationList.Concat(quotation).ToList();
26                 //    for (int k = 0; k < quotation.Count; k++)
27                 //    {
28                 //        SAPPRItemListVM.ListRow row = list[i];
29                 //        row.VendorCode = quotation[k].Vendor.Code;
30                 //        row.VendorName = quotation[k].Vendor.Name;
31                 //        row.FinalPrice = quotation[k].FinalPrice;
32                 //        resultList.Add(row);
33                 //    }
34                 //}
35                 //询价
36                 else if (list[i].QRId != 0)
37                 {
38                     ESC.Domain.DomainModel.QR.QR a = MyQRReader.Get(list[i].QRId);
39                     string[] partList = a.Items.Select(x => x.Part.PartNo).Distinct().ToArray();
40                     IList<Quotation> quotationList = new List<Quotation>();
41                     int pageCount = (int)Math.Ceiling(partList.Length / 1000.0);
42                     for (int p = 0; p < pageCount; p++)
43                     {
44                         if (list[i].RequestedDate.HasValue)
45                         {
46                             //每1000个获取报价。因为有参数个数限制(The server supports a maximum of 2100 parameters.)
47                             string[] arrayPartList = partList.Skip(1000 * p).Take(1000).ToArray();
48                             IList<Quotation> quotations = MyQuotationReader.GetNotAgreementEffectiveQuotation(arrayPartList, list[i].RequestedDate.Value, list[i].LastModifiedTime).List();
49                             foreach (Quotation oQuotation in quotations)
50                             {
51                                 quotationList.Add(oQuotation);
52                             }
53                         }
54                         for (int k = 0; k < quotationList.Count; k++)
55                         {
56                             SAPPRItemDTO row = list[i];
57                             row.VendorCode = quotationList[k].Vendor.Code;
58                             row.VendorName = quotationList[k].Vendor.Name;
59                             row.FinalPrice = quotationList[k].FinalPrice;
60                             resultList.Add(row);
61                         }
62                     }
63                 }
64                 else
65                 {
66                     resultList.Add(list[i]);
67                 }
68             }
69 
70             WorkbookDesigner designer = new WorkbookDesigner();
71             designer.Workbook = new Workbook(Server.MapPath("~/Template/ExportFormat/PRItemSAPExportFormat.xlsx"));
72             designer.SetDataSource("data", resultList);
73             designer.Process();
74             string fileName = Guid.NewGuid().ToString() + ".xlsx";
75             designer.Workbook.Save(Server.MapPath("~/" + ConfigurationManager.AppSettings["DefaultFilePath"] + "/" + fileName));
76             return RcJson(fileName);
77         }