Bladeren bron

团组数据统计
1、团组合作前十的客户TOP10排序
2、已出团客户单位的类型比例图(饼状图-政府团、企业团等)
3、团组数量、人数

LEIYI 8 maanden geleden
bovenliggende
commit
5dc308508b

+ 5 - 3
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1828,7 +1828,9 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             else
             {
 
-                var oldFiles = JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
+                var oldFiles = string.IsNullOrEmpty(oaInfo.ScreenshotOfMailUrl)
+                               ? new List<string>() 
+                               : JsonConvert.DeserializeObject<List<string>>(oaInfo.ScreenshotOfMailUrl);
 
                 if (oldFiles.Count > 0)
                 {
@@ -1837,10 +1839,10 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
 
                 fileUrls = fileUrls.Distinct().ToList();
 
-                if (oldFiles.Count()>0)
+                if (fileUrls.Count()>0)
                 {
                     var upd = await _sqlSugar.Updateable<Res_OfficialActivities>()
-                                          .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(oldFiles))
+                                          .SetColumns(x => x.ScreenshotOfMailUrl == JsonConvert.SerializeObject(fileUrls))
                                           .Where(x => x.Id == dto.id)
                                           .ExecuteCommandAsync();
 

+ 130 - 0
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -3846,6 +3846,136 @@ WHERE
             return Ok(JsonView(true, "操作成功!", groupByData));
         }
 
+        /// <summary>
+        ///  团组数据统计
+        ///  团组合作前十的客户TOP10排序
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost("StatisticsCooperativeCustomer")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> StatisticsCooperativeCustomer(YOYDto _dto)
+        {
+
+            if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
+
+
+            string beginDt = $"{_dto.Year}-01-01 00:00:00",
+                   endDt = $"{_dto.Year}-12-31 23:59:59";
+            DateTime _beginDt = Convert.ToDateTime(beginDt),
+                     _endDt = Convert.ToDateTime(endDt);
+
+            var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>()
+                                            .Where(x => x.IsDel == 0)
+                                            .Where(x => x.IsSure == 1)
+                                            .Where(x => x.VisitDate >= _beginDt && x.VisitDate <= _endDt)
+                                            .ToListAsync();
+
+            var groupInfos1 = groupInfos.GroupBy(x => x.ClientName);
+
+            var view = groupInfos1.Select(x => 
+                                            new { 
+                                                clienName = x.Key, 
+                                                clientUnit = x.FirstOrDefault()?.ClientUnit ?? "", 
+                                                visitsNum = x.Count() 
+                                            }
+                                         )
+                                  .OrderByDescending(x => x.visitsNum)
+                                  .Take(10)
+                                  .ToList();
+            return Ok(JsonView(true, "操作成功!", view));
+        }
+
+        /// <summary>
+        ///  团组数据统计
+        ///  已出团客户单位的类型比例图(饼状图-政府团、企业团等)
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost("StatisticsCooperativeCustomerType")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> StatisticsCooperativeCustomerType(YOYDto _dto)
+        {
+
+            if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
+
+
+            string beginDt = $"{_dto.Year}-01-01 00:00:00",
+                   endDt = $"{_dto.Year}-12-31 23:59:59";
+            DateTime _beginDt = Convert.ToDateTime(beginDt),
+                     _endDt = Convert.ToDateTime(endDt);
+
+            var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>()
+                                            .LeftJoin<Sys_SetData>((di,sd) => di.TeamDid == sd.Id)
+                                            .Where((di, sd) => di.IsDel == 0)
+                                            .Where((di, sd) => di.VisitDate >= _beginDt && di.VisitDate <= _endDt)
+                                            .Select((di, sd) => new { 
+                                                Id = di.Id,
+                                                GroupTypeId = di.TeamDid,
+                                                GroupTypeName = sd.Name,
+                                            })
+                                            .ToListAsync();
+
+
+            var groupInfos1 = groupInfos.GroupBy(x => x.GroupTypeName);
+
+            var view = groupInfos1.Select(x =>
+                                            new {
+                                                groupTypeName = x.Key,
+                                                groupNum = x.Count(),
+                                                linkGroupId = x.Select(x1 => x1.Id).ToList()
+                                            }
+                                         )
+                                  .OrderByDescending(x => x.groupNum)
+                                  .ToList();
+            return Ok(JsonView(true, "操作成功!", view));
+        }
+
+
+        /// <summary>
+        ///  团组数据统计
+        ///  团组数量、人数
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost("StatisticsCooperativeCustomerType")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> StatisticsGroupInfo(YOYDto _dto)
+        {
+
+            if (_dto.Year < 1) return Ok(JsonView(false, "操作失败"));
+
+
+            string beginDt = $"{_dto.Year}-01-01 00:00:00",
+                   endDt = $"{_dto.Year}-12-31 23:59:59";
+            DateTime _beginDt = Convert.ToDateTime(beginDt),
+                     _endDt = Convert.ToDateTime(endDt);
+
+            var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>()
+                                            .Where(x => x.IsDel == 0)
+                                            .Where(x => x.VisitDate >= _beginDt && x.VisitDate <= _endDt)
+                                            .Select(x => new {
+                                                Id = x.Id,
+                                                x.VisitDate,
+                                                Month = x.VisitDate.Month,
+                                                x.VisitPNumber
+                                            })
+                                            .ToListAsync();
+
+
+            var groupInfos1 = groupInfos.GroupBy(x => x.Id);
+
+            var view = groupInfos1.Select(x =>
+                                            new {
+                                                groupTypeName = x.Key,
+                                                groupNum = x.Count(),
+                                                linkGroupId = x.Select(x1 => x1.Id).ToList()
+                                            }
+                                         )
+                                  .OrderByDescending(x => x.groupNum)
+                                  .ToList();
+            return Ok(JsonView(true, "操作成功!", view));
+        }
         #endregion
     }
 }