/// <summary>
        /// 业务逻辑
        /// </summary>
        /// <param name="excelId"></param>
        /// <returns></returns>
        public Stream Process(string ids)
        {
            var excelDatas = new List <List <string> >();

            excelDatas.Add(GetExcelTitel());
            var idsArr      = ids.Split(',');
            var companyList = new List <Company>();
            var areas       = _companyBll.GetAllArea();

            foreach (var id in idsArr)
            {
                if (string.IsNullOrEmpty(id))
                {
                    continue;
                }
                var idArr  = id.Split('_');
                var findId = Convert.ToInt32(idArr[1]);
                if (idArr[0] == "1")
                {
                    var companys = _companyBll.GetCompanyByAreaId(findId);
                    if (companys != null)
                    {
                        companyList.AddRange(companys);
                    }
                }
                else
                {
                    var company = _companyBll.GetCompanyByKey(findId);
                    if (company != null)
                    {
                        companyList.Add(company);
                    }
                }
            }
            foreach (var company in companyList)
            {
                var area           = areas.FirstOrDefault(x => x.AreaId == company.AreaId);
                var companyRecords = _companyBll.GetCompanyconnectrecordByCompanyId(company.CompanyId);
                if (companyRecords != null && companyRecords.Count > 0)
                {
                    foreach (var record in companyRecords)
                    {
                        excelDatas.Add(GetOneCellData(area, company, record));
                    }
                }
                else
                {
                    excelDatas.Add(GetOneCellData(area, company, new CompanyConnectRecord()));
                }
            }
            var excelBuilder = ExcelFactory.CreateBuilder();
            var sheet        = excelBuilder.InsertSheet("sheet1");

            sheet.InsertSheetContent(ExcelExportRequest.GetInstance(excelDatas));
            var stream = new MemoryStream();

            excelBuilder.Save(stream, SaveFormat.Xlsx);
            stream.Position = 0;
            return(stream);
        }
Example #2
0
        public List <GetAllAreaResponse> Process()
        {
            var result  = new List <GetAllAreaResponse>();
            var allArea = _companyBll.GetAllArea();

            if (allArea == null)
            {
                return(result);
            }
            foreach (var area in allArea)
            {
                result.Add(new GetAllAreaResponse()
                {
                    key   = area.AreaId.ToString(),
                    value = area.AreaName
                });
            }
            return(result);
        }
        public List <TreeDataModel> Process(string id)
        {
            var result = new List <TreeDataModel>();

            if (string.IsNullOrEmpty(id) || id == "0")
            {
                var areas = _companyBll.GetAllArea();
                if (areas == null)
                {
                    return(result);
                }
                foreach (var area in areas)
                {
                    result.Add(new TreeDataModel()
                    {
                        id   = "1_" + area.AreaId,
                        text = area.AreaName,
                    });
                }
            }
            else
            {
                var idArr    = id.Split('_');
                var areaId   = Convert.ToInt32(idArr[1]);
                var companys = _companyBll.GetCompanyByAreaId(areaId);
                if (companys == null)
                {
                    return(result);
                }
                foreach (var company in companys)
                {
                    result.Add(new TreeDataModel()
                    {
                        id   = "2_" + company.CompanyId,
                        text = company.CompanyName,
                        leaf = true
                    });
                }
            }
            return(result);
        }