Explorar o código

市场客户资料 Excel 下载

LEIYI hai 2 meses
pai
achega
5222a118e1

+ 18 - 11
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -4,6 +4,7 @@ using OASystem.API.OAMethodLib;
 using OASystem.Domain.AesEncryption;
 using OASystem.Domain.Dtos.CRM;
 using OASystem.Domain.Entities.Customer;
+using OASystem.Domain.ViewModels.CRM;
 using OASystem.Infrastructure.Repositories.CRM;
 using System.Collections;
 using System.Data;
@@ -584,14 +585,13 @@ namespace OASystem.API.Controllers
             if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权!"));
             #endregion
 
-            DataTable dt = await _clientDataRepository.NewClientDataExcelDownload(dto);
-            dt.TableName = $"NCDDT";
+             var dt = await _clientDataRepository.NewClientDataExcelDownload(dto);
             if (dt != null)
             {
-                string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/团组费用统计模板.xls");
+                string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/公司客户资料导出模板.xlsx");
                 var designer = new WorkbookDesigner();
                 designer.Workbook = new Workbook(tempPath);
-                designer.SetDataSource(dt);
+                designer.SetDataSource("NCDDT", dt);
                 designer.Process();
 
                 //文件名
@@ -600,16 +600,23 @@ namespace OASystem.API.Controllers
                 string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/NewClientDataExcelDownload/" + fileName;
 
                 #region 客户资料表操作记录
-                await GeneralMethod.NewClientOperationRecord(dto.PortType, OperationEnum.Download, dto.OperationUserId, 0, "excel导出");
+                var respose = JsonView(true, "成功", url);
+                var paramData = new
+                {
+                    APIName = @"MarketCustomerResources/NewClientDataExcelDownload",
+                    RequestParam = dto,
+                    ResposeParam = respose
+                };
+
+                await GeneralMethod.NewClientOperationRecord(dto.PortType, OperationEnum.Download, dto.OperationUserId, 0, JsonConvert.SerializeObject(paramData));
                 #endregion
 
-                return Ok(JsonView(true, "成功", url));
+                return Ok(respose);
             }
-            else
-            {
-                return Ok(JsonView(false));
-                }
-           
+
+
+            return Ok(JsonView(false));
+
         }
 
 

+ 2 - 2
OASystem/OASystem.Domain/Entities/Customer/Crm_NewClientData.cs

@@ -23,7 +23,7 @@ namespace OASystem.Domain.Entities.Customer
         private string contact;
         private int gender;
         private string passport;
-        private DateTime passportDate;
+        private DateTime? passportDate;
         private string job;
         private string telephone;
         private string phone;
@@ -94,7 +94,7 @@ namespace OASystem.Domain.Entities.Customer
         /// 护照日期
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "DateTime")]
-        public DateTime PassportDate { get => passportDate; set => passportDate = value; }
+        public DateTime? PassportDate { get => passportDate; set => passportDate = value; }
 
         /// <summary>
         /// 职位

+ 15 - 1
OASystem/OASystem.Domain/ViewModels/CRM/NewClientDataView.cs

@@ -265,11 +265,25 @@ namespace OASystem.Domain.ViewModels.CRM
 
         public string CreateUserName { get; set; }
 
+        public string WeightLable {
+            get
+            {
+                if (int.TryParse(Weight,out int weightId))
+                {
+                    if (weightId == 393) return "A";
+                    else if (weightId == 392) return "B";
+                    else if (weightId == 391) return "C";
+                    else return "D";
+                }
+                return "D";
+            }
+        }
+
         public string SexLable
         {
             get
             {
-                return Gender == 0 ? "女" : Gender == 1 ? "男" : "未设置";
+                return Gender == 0 ? "男" : Gender == 1 ? "女" : "未设置";
             }
         }
 

+ 4 - 5
OASystem/OASystem.Infrastructure/Repositories/CRM/NewClientDataRepository.cs

@@ -1407,9 +1407,9 @@ namespace OASystem.Infrastructure.Repositories.CRM
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
-        public async Task<DataTable> NewClientDataExcelDownload(NewClientDataExcelDownloadDto dto)
+        public async Task<List<NewClientDataExcelDownloadView>> NewClientDataExcelDownload(NewClientDataExcelDownloadDto dto)
         {
-            var dt = new DataTable();
+            var dt =  new List<NewClientDataExcelDownloadView>();
 
             try
             {
@@ -1596,7 +1596,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
 
                 if (!NewClientDataView.Any()) return dt;
 
-                var userDatas = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToListAsync();
+                var userDatas = await _sqlSugar.Queryable<Sys_Users>().ToListAsync();
                 var setDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToListAsync();
                 var ascribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
                   ("select u1.UsersId as UserId ,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id AND u1.ISDEL = 0").ToListAsync();
@@ -1621,8 +1621,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
                     index++;
                 }
 
-                dt = CommonFun.ToDataTableArray(NewClientDataView);
-                return dt;
+                return NewClientDataView;
 
             }
             catch (Exception ex)