ソースを参照

会务数据统计-会务城市TOP10排序 代码编写

amigotrip 1 年間 前
コミット
6c34293366
共有1 個のファイルを変更した67 個の追加39 個の削除を含む
  1. 67 39
      OASystem/OASystem.Api/Controllers/StatisticsController.cs

+ 67 - 39
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -1,39 +1,14 @@
-using Microsoft.AspNetCore.Mvc;
-using NPOI.POIFS.Properties;
-using NPOI.SS.Formula.Functions;
+using Aspose.Cells;
 using OASystem.API.OAMethodLib;
-using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.Statistics;
-using OASystem.Domain.Entities.Financial;
+using OASystem.Domain.Entities.Customer;
+using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Financial;
-using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.Statistics;
 using OASystem.Infrastructure.Repositories.Groups;
-using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
-using System;
-using OASystem.Domain.Entities.Customer;
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using Microsoft.VisualBasic;
-using OASystem.Domain.Entities.Groups;
-using Microsoft.Extensions.DependencyInjection;
-using Aspose.Words.Lists;
+using System.Data;
 using static OASystem.API.OAMethodLib.GeneralMethod;
 using TypeInfo = OASystem.Domain.ViewModels.Statistics.TypeInfo;
-using System.Net.NetworkInformation;
-using System.ComponentModel.Design;
-using NetTaste;
-using OASystem.Domain.ViewModels.QiYeWeChat;
-using NPOI.POIFS.Crypt.Dsig;
-using EyeSoft.SequentialIdentity;
-using Microsoft.Extensions.Configuration;
-using System.Text.Json;
-using OASystem.RedisRepository;
-using OASystem.RedisRepository.RedisAsyncHelper;
-using System.Data;
-using OfficeOpenXml.Export.ToDataTable;
-using Aspose.Cells;
-using NPOI.OpenXmlFormats.Wordprocessing;
 
 namespace OASystem.API.Controllers
 {
@@ -3256,14 +3231,8 @@ Where dfp.IsDel = 0 And dfp.IsPay = 1
 
         #endregion
 
-
         #region 统计模块
-        /*
-         * 1、营业额(今年和去年的)、成本支出(今年和去年的)、毛利润(今年和去年的)
-2、国交数据统计(1、机票票数、2、机票到达地 3、酒店预订地区TOP10排序、酒店房型地区间数、商邀邀请国家数量TOP10排序)
-3、会务数据统计(1、会务城市TOP10排序
-         * 
-         */
+      
         /// <summary>
         ///  同比
         ///  营业额(今年和去年的)、成本支出(今年和去年的)、毛利润(今年和去年的)
@@ -3465,6 +3434,7 @@ FROM
   Grp_DelegationInfo di
 WHERE
   di.IsDel = 0
+  AND di.TeamDid IN (38,39,40,1048)
   AND di.IsSure = 1
   AND di.VisitDate BETWEEN '{0}' AND '{1}'
 ORDER BY
@@ -3540,9 +3510,11 @@ FROM
   INNER JOIN Grp_CreditCardPayment ccp ON atr.Id = ccp.CId
   AND ccp.IsDel = 0
   AND CTable = 85
-  Left Join Sys_SetData sd On atr.CType = sd.Id
+  INNER JOIN Grp_DelegationInfo di ON atr.DIId = di.Id
+  LEFT JOIN Sys_SetData sd On atr.CType = sd.Id
 WHERE
   atr.IsDel = 0
+  AND di.TeamDid IN (38,39,40,1048)
   And atr.CType IN(457,458,459,460,574,575)
   AND CHARINDEX('行程单',atr.ClientName) = 0
   AND CHARINDEX('返点',atr.ClientName) = 0
@@ -3675,7 +3647,6 @@ WHERE
             return Ok(JsonView(true, "操作成功!", new { airTicketNumData = airTicketNumData, airTicketAreaData = airTicketAreaData }));
         }
 
-
         /// <summary>
         ///  国交数据统计
         ///  酒店预订地区TOP10
@@ -3694,6 +3665,7 @@ WHERE
                    endDt = $"{_dto.Year}-12-31 23:59:59";
 
             string sql = string.Format(@"
+
 SELECT
   hr.DIId,
   hr.City,
@@ -3712,9 +3684,11 @@ FROM
   INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
   AND ccp.IsDel = 0
   AND CTable = 76
+  INNER JOIN Grp_DelegationInfo di ON hr.DiId = di.Id
   LEFT JOIN Sys_SetData sd ON hr.ReservationsWebsite = sd.Id
 WHERE
   hr.IsDel = 0
+  AND di.TeamDid IN (38,39,40,1048)
   AND ccp.IsPay = 1
   AND (
     hr.SingleRoomCount > 0
@@ -3738,7 +3712,7 @@ WHERE
   AND hr.CheckInDate BETWEEN '{0}' AND '{1}'
 ORDER BY
   hr.CheckInDate
-",beginDt,endDt);
+", beginDt,endDt);
 
             var data = await _sqlSugar.SqlQueryable<StatisticsHotelView>(sql).ToListAsync();
 
@@ -3796,8 +3770,10 @@ FROM
   INNER JOIN Grp_CreditCardPayment ccp ON ioa.Id = ccp.CId
   AND ccp.IsDel = 0
   AND ccp.CTable = 81
+  INNER JOIN Grp_DelegationInfo di ON ioa.DiId = di.Id
 WHERE
   ioa.IsDel = 0
+  AND di.TeamDid IN (38,39,40,1048)
   AND ccp.IsPay = 1
   AND ioa.CreateTime BETWEEN '{0}' AND '{1}'
 ", beginDt, endDt);
@@ -3819,6 +3795,58 @@ WHERE
             return Ok(JsonView(true, "操作成功!", groupByData));
         }
 
+        /// <summary>
+        ///  会务数据统计
+        ///  会务城市TOP10排序
+        /// </summary>
+        /// <param name="_dto"></param>
+        /// <returns></returns>
+        [HttpPost("StatisticsConferenceCity")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> StatisticsConferenceCity(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";
+
+            string sql = string.Format(@"
+SELECT
+  ioa.DiId,
+  ioa.InviterArea AS Country
+FROM
+  Grp_InvitationOfficialActivities ioa
+  INNER JOIN Grp_CreditCardPayment ccp ON ioa.Id = ccp.CId
+  AND ccp.IsDel = 0
+  AND ccp.CTable = 81
+  INNER JOIN Grp_DelegationInfo di ON ioa.DiId = di.Id
+WHERE
+  ioa.IsDel = 0
+  AND di.TeamDid IN (102,248,302,691,762,1047)
+  AND ccp.IsPay = 1
+  AND ioa.CreateTime BETWEEN '{0}' AND '{1}'
+", beginDt, endDt);
+
+            var data = await _sqlSugar.SqlQueryable<StatisticsInvitation>(sql).ToListAsync();
+
+            var groupByData = data.GroupBy(x => x.Country)
+                                  .Select(g => new
+                                  {
+                                      Country = g.Key,
+                                      TimeNum = g.Count(),
+                                      LinkGroupIds = g.Select(x => x.DIId).ToList()
+
+                                  })
+                                  .OrderByDescending(x => x.TimeNum)
+                                  .Take(10)
+                                  .ToList();
+
+            return Ok(JsonView(true, "操作成功!", groupByData));
+        }
+
+
         #endregion
     }
 }