public async Task <TData <List <AreaEntity> > > GetList(AreaListParam param) { TData <List <AreaEntity> > obj = new TData <List <AreaEntity> >(); List <AreaEntity> areaList = await areaCache.GetList(); if (param != null) { if (!param.AreaName.IsEmpty()) { areaList = areaList.Where(t => t.AreaName.Contains(param.AreaName)).ToList(); } } obj.Data = areaList; obj.Tag = 1; return(obj); }
public ActionResult GetTreeJson(string value) { string parentId = string.IsNullOrEmpty(value) ? "0" : value; var filterdata = areaCache.GetList(parentId).ToList(); StringBuilder sb = new StringBuilder(); sb.Append("["); if (filterdata.Count > 0) { foreach (AreaEntity item in filterdata) { bool hasChildren = areaCache.GetList(item.Id).ToList().Count != 0; sb.Append("{"); sb.Append("\"id\":\"" + item.Id + "\","); sb.Append("\"text\":\"" + item.AreaName + "\","); sb.Append("\"value\":\"" + item.Id + "\","); sb.Append("\"isexpand\":false,"); sb.Append("\"complete\":false,"); sb.Append("\"hasChildren\":" + hasChildren.ToString().ToLower() + ""); sb.Append("},"); } sb = sb.Remove(sb.Length - 1, 1); } sb.Append("]"); return(Content(sb.ToString())); //var treeList = new List<TreeEntity>(); //foreach (AreaEntity item in filterdata) //{ // TreeEntity tree = new TreeEntity(); // //bool hasChildren = areaCache.GetList(item.Id).ToList().Count != 0; // bool hasChildren = filterdata.Count(t => t.ParentId == item.Id) != 0; // tree.id = item.Id; // tree.text = item.AreaName; // tree.value = item.Id; // tree.parentId = item.ParentId; // tree.isexpand = true; // tree.complete = true; // tree.hasChildren = hasChildren; // treeList.Add(tree); //} ////return Json(treeList, JsonRequestBehavior.AllowGet); //return Content(treeList.TreeToJson()); }
public ActionResult GetAreaTreeJson() { var data = areaCache.GetList().ToList(); var treeList = new List <TreeEntity>(); foreach (AreaEntity item in data) { TreeEntity tree = new TreeEntity(); bool hasChildren = data.Count(t => t.ParentId == item.AreaId) == 0 ? false : true; tree.id = item.AreaId; tree.text = item.AreaName; tree.value = item.AreaId; tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; tree.parentId = item.ParentId; tree.Index = item.Layer; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }
/// <summary> /// 行政区域数据 /// </summary> /// <returns></returns> private object GetAreaData() { var data = areaCache.GetList(); Dictionary <string, object> dictionary = new Dictionary <string, object>(); foreach (AreaEntity item in data) { var fieldItem = new { AreaCode = item.AreaCode, AreaName = item.AreaName, ParentId = item.ParentId, }; dictionary.Add(item.AreaId, fieldItem); } return(dictionary); }
/// <summary> /// 设置客户实体数据 /// </summary> /// <param name="entity">客户实体</param> /// <param name="title">Excel导入的列名</param> /// <param name="cellValue">单元格值</param> /// <returns></returns> public string SetCustomerValue(CustomerEntity entity, string title, string cellValue) { string result = string.Empty; switch (title) { case "原主键": entity.ShortName = cellValue; break; case "客户名称": cellValue = cellValue.Replace(" ", ""); if (cellValue.Length <= 3) { result = "客户名称不完整"; break; } //System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^([\u4e00-\u9fa5]*[((]?[\u4e00-\u9fa5]+[))]?[\u4e00-\u9fa5]*)$"); //if (!reg.IsMatch(cellValue)) //{ // result = "客户名称只能包含汉字和括弧"; // break; //} entity.FullName = cellValue; break; case "客户级别": var Client_Level = dataItemCache.GetDataItemList("Client_Level").FirstOrDefault(s => s.ItemName == cellValue); if (Client_Level != null) { entity.CustLevelId = Client_Level.ItemDetailId; } else { result = "客户级别不正确"; } break; case "企业性质": var Client_NatureCode = dataItemCache.GetDataItemList("Client_NatureCode").FirstOrDefault(s => s.ItemName.Contains(cellValue)); if (Client_NatureCode != null) { entity.NatureCode = Client_NatureCode.ItemDetailId; } else if (!string.IsNullOrWhiteSpace(cellValue)) { entity.NatureCode = dataItemCache.GetDataItemList("Client_NatureCode").First().ItemDetailId; } else { result = "企业性质不正确"; } break; case "注册资金": var Client_RegisterCapital = dataItemCache.GetDataItemList("Client_RegisterCapital").FirstOrDefault(s => s.ItemName == cellValue); if (Client_RegisterCapital != null) { entity.RegisterCapital = Client_RegisterCapital.ItemDetailId; } else if (!string.IsNullOrWhiteSpace(cellValue)) { entity.RegisterCapital = dataItemCache.GetDataItemList("Client_RegisterCapital").First().ItemDetailId; } else { result = "注册资金不正确"; } break; case "销售收入": var Client_SalesRevenue = dataItemCache.GetDataItemList("Client_SalesRevenue").FirstOrDefault(s => s.ItemName == cellValue); if (Client_SalesRevenue != null) { entity.SalesRevenue = Client_SalesRevenue.ItemDetailId; } else if (!string.IsNullOrWhiteSpace(cellValue)) { entity.SalesRevenue = dataItemCache.GetDataItemList("Client_SalesRevenue").First().ItemDetailId; } else { result = "销售收入不正确"; } break; case "所属行业": var Client_Trade = dataItemCache.GetDataItemList("Client_Trade").FirstOrDefault(s => s.ItemName == cellValue); if (Client_Trade != null) { entity.CustIndustryId = Client_Trade.ItemDetailId; } else if (!string.IsNullOrWhiteSpace(cellValue)) { entity.CustIndustryId = dataItemCache.GetDataItemList("Client_Trade").First().ItemDetailId; } else { result = "所属行业不正确"; } break; case "公司规模": var Client_CompanySize = dataItemCache.GetDataItemList("Client_CompanySize").FirstOrDefault(s => s.ItemName == cellValue); if (Client_CompanySize != null) { entity.CompanySize = Client_CompanySize.ItemDetailId; } else if (!string.IsNullOrWhiteSpace(cellValue)) { entity.CompanySize = dataItemCache.GetDataItemList("Client_CompanySize").First().ItemDetailId; } else { result = "公司规模不正确"; } break; case "客户来源": var Client_CustomerSource = dataItemCache.GetDataItemList("Client_CustomerSource").FirstOrDefault(s => s.ItemName == cellValue); if (Client_CustomerSource != null) { entity.CustomerSource = Client_CustomerSource.ItemDetailId; } else if (!string.IsNullOrWhiteSpace(cellValue)) { entity.CustomerSource = dataItemCache.GetDataItemList("Client_CustomerSource").First().ItemDetailId; } break; case "联系人": entity.Contact = cellValue; break; case "职位": var Client_Post = dataItemCache.GetDataItemList("Client_Post").FirstOrDefault(s => s.ItemName == cellValue); if (Client_Post != null) { entity.PostId = Client_Post.ItemDetailId; } break; case "固定电话": entity.Tel = cellValue; break; case "手机号码": entity.Mobile = cellValue; break; case "邮箱": entity.Email = cellValue; break; case "所在省份": case "省份": cellValue = cellValue.TrimEnd('省'); var province = areaCache.GetList().FirstOrDefault(s => s.AreaName.Contains(cellValue)); if (province != null) { entity.ProvinceId = province.AreaId; } break; case "所在城市": case "城市": cellValue = cellValue.TrimEnd('市'); var city = areaCache.GetList().FirstOrDefault(s => s.AreaName.Contains(cellValue)); if (city != null) { entity.CityId = city.AreaId; } break; case "详细地址": entity.CompanyAddress = cellValue; break; case "官网": entity.CompanySite = cellValue; break; case "公司简介": entity.CompanyDesc = cellValue; break; case "备注": entity.Description = cellValue; break; case "归属人": var user = userCache.GetList().Where(s => s.Account == cellValue).FirstOrDefault(); if (user != null) { entity.TraceUserId = user.UserId; entity.TraceUserName = user.RealName; } break; } return(result); }