/// <summary> /// 获取供货计划数据 /// </summary> /// <param name="context"></param> /// <returns></returns> public string GetSupplyPlanPageList(HttpContext context) { ///page int pageIndex = 1; string indexPage = context.Request["page"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(indexPage)) { pageIndex = int.Parse(indexPage); } ///rows int maxRow = int.MaxValue; string rowMax = context.Request["rows"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(rowMax)) { maxRow = int.Parse(rowMax); } ///sort string orderText = string.Empty; if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["sort"])) { orderText += context.Request["sort"]; if (!orderText.Contains("_")) { orderText = DataCommon.GetFieldName(orderText.Trim()); } } ///order if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["order"])) { orderText += " " + context.Request["order"]; } ///FILTER string strWhere = context.Request["FILTER"]; if (HttpCommon.IsNullOrEmptyOrUndefined(strWhere)) { strWhere = string.Empty; } if (strWhere.Trim().ToUpper() == "AND") { strWhere = string.Empty; } ///ENTITY_AUTH string entityAuth = context.Request["ENTITY_AUTH"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(entityAuth)) { strWhere += entityAuth.Replace("^", "'"); } DataTable dt = GetSupplyPlanData(strWhere, orderText, pageIndex, maxRow, out int dataTotal); string result = JsonHelper.DataTableToJson(dt); return(@"{""rows"":" + result + @",""total"":" + dataTotal + @"}"); }
/// <summary> /// 获取数据集合 /// </summary> /// <param name="context">ENTITY_NAME,AN,page,rows,sort,order,FILTER,SECOND_FILTER,AUTH_FILTER,URL_FILTER,COMBOGRID_FILTER,q</param> /// <returns></returns> /// SUPPLIER_PART_QUOTA public static string GetSupplierPartQuotaTableData(HttpContext context) { ///ENTITY_NAME string entityName = context.Request["ENTITY_NAME"]; if (entityName.IndexOf("_") != -1) { entityName = entityName.Substring(0, entityName.IndexOf("_")); } entityName = entityName.Replace("Init", string.Empty); ///AN string assemblyName = context.Request["AN"]; if (HttpCommon.IsNullOrEmptyOrUndefined(assemblyName)) { assemblyName = "BLL.SYS"; } ///page int pageIndex = 1; string indexPage = context.Request["page"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(indexPage)) { pageIndex = int.Parse(indexPage); } ///rows int maxRow = int.MaxValue; string rowMax = context.Request["rows"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(rowMax)) { maxRow = int.Parse(rowMax); } ///sort string orderText = string.Empty; if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["sort"])) { orderText += context.Request["sort"]; if (!orderText.Contains("_")) { orderText = DataCommon.GetFieldName(orderText.Trim()); } } ///order if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["order"])) { orderText += " " + context.Request["order"]; } ///FILTER string strWhere = context.Request["FILTER"]; if (HttpCommon.IsNullOrEmptyOrUndefined(strWhere)) { strWhere = string.Empty; } if (strWhere.Trim().ToUpper() == "AND") { strWhere = string.Empty; } ///SECOND_FILTER string secondFilter = context.Request["SECOND_FILTER"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(secondFilter)) { strWhere += " " + secondFilter; } ///AUTH_FILTER string authFilter = context.Request["AUTH_FILTER"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(authFilter)) { strWhere += " " + authFilter; } ///ENTITY_AUTH string entityAuth = context.Request["ENTITY_AUTH"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(entityAuth)) { strWhere += entityAuth.Replace("^", "'"); } ///URL_FILTER string urlFilter = context.Request["URL_FILTER"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(urlFilter)) { string[] urlFilters = urlFilter.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var urlFilterCondition in urlFilters) { strWhere += " and " + urlFilterCondition + " "; } } ///COMBOGRID_FILTER string combogridFilter = context.Request["COMBOGRID_FILTER"]; string cbogridFilterQ = context.Request["q"]; if (!HttpCommon.IsNullOrEmptyOrUndefined(combogridFilter) && !HttpCommon.IsNullOrEmptyOrUndefined(cbogridFilterQ)) { string[] combofilters = combogridFilter.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); string sqlTempWhere = string.Empty; foreach (string combofilter in combofilters) { sqlTempWhere += "or charindex('" + cbogridFilterQ + "'," + combofilter + ") > 0 "; } strWhere += " and (" + sqlTempWhere.Substring(2) + ") "; } string wmNo = context.Request["FILTERS"].ToString(); /// int dataTotal = 0; object list = new object(); switch (entityName) { case "SupplierPartQuota": list = new SupplierPartQuotaBLL().GetListByPages(strWhere.Replace("^", "'"), pageIndex, maxRow, wmNo, out dataTotal); break; default: break; } string result = JsonHelper.ToJson(list); return(@"{""rows"":" + result + @",""total"":" + dataTotal + @"}"); }
/// <summary> /// 供货计划相关EXCEL导出 /// </summary> /// <param name="context"></param> /// <returns></returns> public string SupplyPlanExportExcel(HttpContext context) { ///ENTITY_NAME string entityName = context.Request["ENTITY_NAME"]; if (entityName.IndexOf("_") != -1) { entityName = entityName.Substring(0, entityName.IndexOf("_")); } if (HttpCommon.IsNullOrEmptyOrUndefined(entityName)) { throw new Exception("MC:1x00000030");///参数获取错误 } ///fileName string fileName = entityName + DateTime.Now.Ticks + ".xlsx"; ///filePath string filePath = HttpContext.Current.Server.MapPath("/TEMP/EXPORTFILES"); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } ///sort string orderText = string.Empty; if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["sort"])) { orderText += context.Request["sort"]; if (!orderText.Contains("_")) { orderText = DataCommon.GetFieldName(orderText.Trim()); } } ///order if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["order"])) { orderText += " " + context.Request["order"]; } ///FILTER string textWhere = context.Request["FILTER"]; if (HttpCommon.IsNullOrEmptyOrUndefined(textWhere)) { textWhere = string.Empty; } if (textWhere.Trim().ToUpper() == "AND") { textWhere = string.Empty; } ///创建标题行 List <EntityFieldInfo> entityFieldInfos = new List <EntityFieldInfo>(); switch (entityName) { ///供货计划 case "SupplyPlan": entityFieldInfos = GetSupplyPlanFields(textWhere, entityName) .OrderBy(d => d.DisplayOrder.GetValueOrDefault()) .OrderBy(d => d.ExportExcelOrder.GetValueOrDefault()).ToList(); break; ///缺件检查 case "LackOfInspection": entityFieldInfos = GetSupplyPlanCheckFields(textWhere, entityName) .OrderBy(d => d.DisplayOrder.GetValueOrDefault()) .OrderBy(d => d.ExportExcelOrder.GetValueOrDefault()).ToList(); break; } if (entityFieldInfos.Count == 0) { throw new Exception("MC:1x00000033");///未设置导出内容 } ///CODE_ITEM下拉菜单集合 Dictionary <string, Dictionary <string, string> > dicDropdowns = new Dictionary <string, Dictionary <string, string> >(); Dictionary <string, string> columnNames = SYSHandler.GetExcelColumnNames(entityFieldInfos, ref dicDropdowns); ///page int pageIndex = 1; ///rows int maxRow = int.MaxValue; int dataTotal; ///获取数据 DataTable dataTable = new DataTable(); switch (entityName) { ///供货计划 case "SupplyPlan": dataTable = GetSupplyPlanData(textWhere, orderText, pageIndex, maxRow, out dataTotal); break; ///缺件检查 case "LackOfInspection": dataTable = GetLackOfInspectionData(textWhere, orderText, pageIndex, maxRow, out dataTotal); break; } if (dataTable.Rows.Count > 65535) { throw new Exception("MC:1x00000036");///导出数据不能多于65535条 } ///NPOI NpoiHelper.TableToExcel(dataTable, columnNames, dicDropdowns, entityName, filePath + @"\" + fileName); /// return("../TEMP/EXPORTFILES/" + fileName); }