Ver código fonte

优化数据处理和空值检查

在 `FinancialController.cs` 中增加了对 `groupResult.dataList` 和 `dailyResult.dataList` 的空值检查,以避免空引用异常。
在 `StatisticsController.cs` 中添加了新的命名空间 `NPOI.XSSF.Streaming.Values`,并重构了多个方法以优化数据获取和处理逻辑,确保团组报表的准确性和完整性。
在 `DelegationInfoRepository.cs` 中优化了 `GroupEditBasicSource` 方法,增加了数据源检查,简化了代码逻辑。
LEIYI 2 meses atrás
pai
commit
a05d063038

+ 2 - 2
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -3191,8 +3191,8 @@ namespace OASystem.API.Controllers
                 var _GroupData = new List<tree_Group_DailyFeePaymentPageListView>();
                 var _DailyData = new List<tree_Fin_DailyFeePaymentPageListView>();
 
-                if (groupResult.dataList.Any()) _GroupData = groupResult.dataList.Where(it => it.CompanyId == dto.ConpanyId).ToList();
-                if (dailyResult.dataList.Any()) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == dto.ConpanyId).ToList();
+                if (groupResult.dataList != null && groupResult.dataList.Any()) _GroupData = groupResult.dataList.Where(it => it.CompanyId == dto.ConpanyId).ToList();
+                if (dailyResult.dataList != null && dailyResult.dataList.Any()) _DailyData = dailyResult.dataList.Where(it => it.CompanyId == dto.ConpanyId).ToList();
 
                 ////1	成都泛美商务有限公司
                 //if (dto.ConpanyId == 1)

Diferenças do arquivo suprimidas por serem muito extensas
+ 872 - 841
OASystem/OASystem.Api/Controllers/StatisticsController.cs


+ 42 - 50
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -493,64 +493,56 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
-            try
+            if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
             {
-                if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) //web
+                dynamic? teamTypeData1 = null;
+                string teamTypeSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
+                var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ;  //团组分类 10
+                if (teamTypeData.Any())
                 {
-                    dynamic? teamTypeData1 = null;
-                    string teamTypeSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
-                    var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ;  //团组分类 10
-                    if (teamTypeData.Count > 0)
-                    {
-                        teamTypeData1 = teamTypeData;
-                    }
-
-                    dynamic? teamLevData1 = null;
-                    string teamLevSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
-                    var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ;  //团组等级 56
-                    if (teamLevData.Count > 0)
-                    {
-                        teamLevData1 = teamLevData;
-                    }
+                    teamTypeData1 = teamTypeData;
+                }
 
-                    dynamic? userData1 = null;
-                    string userSql = string.Format(@"Select Id,CnName From  Sys_Users Where IsDel = {0}", 0);
-                    var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync(); 
-                    if (userData.Count > 0)
-                    {
-                        userData1 = userData;
-                    }
+                dynamic? teamLevData1 = null;
+                string teamLevSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
+                var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ;  //团组等级 56
+                if (teamLevData.Any())
+                {
+                    teamLevData1 = teamLevData;
+                }
 
-                    //客户单位数据源 来源市场客户资料
-                    dynamic? clientData1 = null;
-                    string clientSql = $@"Select Client,Contact,Telephone,WeChat From Crm_NewClientData Where IsDel = 0";
-                    var clientData = await _sqlSugar.SqlQueryable<Crm_NewClientData>(clientSql).ToListAsync();
-                    if (clientData.Count > 0)
-                    {
-                        clientData1 = clientData.Select(it => new
-                        {
-                            Client = AesEncryptionHelper.Decrypt(it.Client),
-                            Contact = AesEncryptionHelper.Decrypt(it.Contact),
-                            Telephone = AesEncryptionHelper.Decrypt(it.Telephone),
-                            Wechat = AesEncryptionHelper.Decrypt(it.Wechat)
-                        }).ToList();
-                    }
+                dynamic? userData1 = null;
+                string userSql = string.Format(@"Select Id,CnName From  Sys_Users Where IsDel = {0}", 0);
+                var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync();
+                if (userData.Any())
+                {
+                    userData1 = userData;
+                }
 
-                    result.Code = 0;
-                    result.Msg = "成功!";
-                    result.Data = new
+                //客户单位数据源 来源市场客户资料
+                dynamic? clientData1 = null;
+                string clientSql = $@"Select Client,Contact,Telephone,WeChat From Crm_NewClientData Where IsDel = 0";
+                var clientData = await _sqlSugar.SqlQueryable<Crm_NewClientData>(clientSql).ToListAsync();
+                if (clientData.Any())
+                {
+                    clientData1 = clientData.Select(it => new
                     {
-                        teamTypeData = teamTypeData1,
-                        teamLevData = teamLevData1,
-                        userData = userData1,
-                        clientData = clientData1
-                    };
+                        Client = AesEncryptionHelper.Decrypt(it.Client),
+                        Contact = AesEncryptionHelper.Decrypt(it.Contact),
+                        Telephone = AesEncryptionHelper.Decrypt(it.Telephone),
+                        Wechat = AesEncryptionHelper.Decrypt(it.Wechat)
+                    }).ToList();
                 }
-            }
-            catch (Exception ex)
-            {
 
-                result.Msg = ex.Message;
+                result.Code = 0;
+                result.Msg = "成功!";
+                result.Data = new
+                {
+                    teamTypeData = teamTypeData1,
+                    teamLevData = teamLevData1,
+                    userData = userData1,
+                    clientData = clientData1
+                };
             }