cyzhao 3 жил өмнө
parent
commit
360c3fdc5f

+ 0 - 2
CSserver/DataTransfer/DataTransfer.csproj

@@ -11,9 +11,7 @@
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
-    <PackageReference Include="MySql.Data" Version="8.0.25" />
     <PackageReference Include="NPOI" Version="2.5.4" />
     <PackageReference Include="NPOI" Version="2.5.4" />
-    <PackageReference Include="StackExchange.Redis" Version="2.2.50" />
   </ItemGroup>
   </ItemGroup>
 
 
   <ItemGroup>
   <ItemGroup>

+ 6 - 5
CSserver/DataTransfer/Program.cs

@@ -46,7 +46,7 @@ namespace DataTransfer
                         Console.WriteLine("数据传输的时间到了开始执行程序.......");
                         Console.WriteLine("数据传输的时间到了开始执行程序.......");
                         //进行数据传输
                         //进行数据传输
                         mask = 1;                        
                         mask = 1;                        
-                        dataTransfer();                      
+                        //dataTransfer();                      
                     }
                     }
 
 
                     if (hour != 2 && mask != 0)
                     if (hour != 2 && mask != 0)
@@ -55,8 +55,8 @@ namespace DataTransfer
                     }
                     }
 
 
                     #region------流失玩家指标分析
                     #region------流失玩家指标分析
-
-                    if (hour == 17 && mask_lose == 0)//正式的是晚上2点进行数据传输
+                    //【解释:次日、2日、3日、4日、5日、6日、7日的流失玩家的uid和该玩家的信息统计\\redis中保存一份,execl文件也存一份】
+                    if (hour == 2 && mask_lose == 0)//正式的是晚上2点进行数据传输
                     {
                     {
                         Console.WriteLine("统计信息程序开始执行............");
                         Console.WriteLine("统计信息程序开始执行............");
                         //进行数据传输
                         //进行数据传输
@@ -64,7 +64,7 @@ namespace DataTransfer
                         UserStatistics.DataDeal();                     
                         UserStatistics.DataDeal();                     
                     }
                     }
 
 
-                    if (hour != 17 && mask_lose != 0)
+                    if (hour != 2 && mask_lose != 0)
                     {
                     {
                         mask_lose = 0;
                         mask_lose = 0;
                     }
                     }
@@ -83,7 +83,8 @@ namespace DataTransfer
             Console.WriteLine("进入dataTransfer方法..............");
             Console.WriteLine("进入dataTransfer方法..............");
 
 
             TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1);
             TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1);
-            float day = MathF.Floor((long)ts.TotalSeconds / 24 / 60 / 60);
+            float curday = MathF.Floor((long)ts.TotalSeconds / 24 / 60 / 60);
+            float day = curday - 1;
             Console.WriteLine("当前天是:" + day);
             Console.WriteLine("当前天是:" + day);
 
 
             var mem = Redis.Ins.GetDatabase(0);
             var mem = Redis.Ins.GetDatabase(0);

+ 9 - 2
CSserver/DataTransfer/tongji/UserStatistics.cs

@@ -221,11 +221,18 @@ namespace DataTransfer.tongji
 
 
             var mem = Redis.Ins.GetDatabase(0);
             var mem = Redis.Ins.GetDatabase(0);
             HashEntry[] ctxList = mem.HashGetAll(MemKey_Statistics.GamerunLoginUser(zoneid, day - 1));
             HashEntry[] ctxList = mem.HashGetAll(MemKey_Statistics.GamerunLoginUser(zoneid, day - 1));
-            int length = ctxList.Length;
+            //int length = ctxList.Length;
 
 
+            List<string> uidlist = new List<string>();
+            foreach (var item in ctxList)
+            {            
+                string[] sList = item.ToString().Split(':');
+                string uid = sList[0];
+                uidlist.Add(uid);
+            }
 
 
             List<HashEntry> list = new List<HashEntry>();
             List<HashEntry> list = new List<HashEntry>();
-            HashEntry d = new HashEntry(day-1, length);
+            HashEntry d = new HashEntry(day-1,uidlist.ToString());
             list.Add(d);
             list.Add(d);
 
 
             mem.HashSet(MemKey_Statistics.userNumRecord(zoneid), list.ToArray());
             mem.HashSet(MemKey_Statistics.userNumRecord(zoneid), list.ToArray());

+ 24 - 0
CSserver/StatisticsTransfer/Program.cs

@@ -0,0 +1,24 @@
+//using System.Collections.Generic;
+//using System.Linq;
+//using Newtonsoft.Json;
+//using Newtonsoft.Json.Linq;
+//using System.Diagnostics;
+
+namespace StatisticsTransfer {
+
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            Console.WriteLine("统计信息从redis---execl文件........");
+
+            //Thread t1 = new Thread(transfer);
+            //t1.Start();
+
+            //dataSav();
+        }
+    }
+
+}
+
+

+ 18 - 0
CSserver/StatisticsTransfer/StatisticsTransfer.csproj

@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net6.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="NPOI" Version="2.5.5" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Lib1\Lib1.csproj" />
+  </ItemGroup>
+
+</Project>

+ 362 - 0
CSserver/StatisticsTransfer/tongji/TargetStatistics.cs

@@ -0,0 +1,362 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using NPOI.HSSF.UserModel;
+using StackExchange.Redis;
+using Newtonsoft.Json.Linq;
+using System.IO;
+using CSharpUtil;
+
+namespace StatisticsTransfer.tongji
+{
+    class TargetStatistics
+    {
+        /// <summary>
+        /// 指标累计值数据转为execl表
+        /// </summary>
+        public static void TargetValToExecl()
+        {
+            var mem = Redis.Ins.GetDatabase(0);
+
+            int zoneid = 1;
+            HashEntry[] ctxList = mem.HashGetAll(MemKey_Statistics.TargetStatistics(zoneid));
+            int length = ctxList.Length;
+            if (length <= 0)
+            {
+                return;
+            }
+
+
+            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();
+
+            foreach (var item in ctxList)
+            {
+                string[] sList = item.ToString().Split(':');
+                string type = sList[0];
+                int num = int.Parse(sList[1]);
+
+                string[] clist = type.Split('-');
+                string nType = targetType(clist[0]);
+                //Console.WriteLine("nType-----.." + nType);
+                if (dic.ContainsKey(nType))
+                {
+                    //Console.WriteLine("type-----..." + type);
+                    dic[nType].Add(type, num);
+                }
+                else
+                {
+                    Dictionary<string, int> itemDic = new Dictionary<string, int>();
+                    itemDic.Add(type, num);
+                    dic[nType] = itemDic;
+                    //Console.WriteLine("type-----..." + type);
+                }
+            }
+
+            HSSFWorkbook workbook = new HSSFWorkbook();
+
+            foreach (KeyValuePair<string, Dictionary<string, int>> kv in dic)
+            {
+                Dictionary<string, int> dict = kv.Value;
+                Console.WriteLine("kv--key-----........" + kv.Key);
+
+                string tableName = "指标统计表_" + kv.Key;
+                //创建工作表            
+                var sheet = workbook.CreateSheet(tableName);
+                var row = sheet.CreateRow(0);
+                //创建单元格
+                var cellid = row.CreateCell(0);
+                cellid.SetCellValue("指标描述信息");
+                var cellname = row.CreateCell(1);
+                cellname.SetCellValue("指标类型");
+                var cellpwd = row.CreateCell(2);
+                cellpwd.SetCellValue("指标累计值");
+                int x = 1;
+                foreach (KeyValuePair<string, int> kt in dict)
+                {
+                    string type = kt.Key;
+                    int num = kt.Value;
+                    string desc = TargetDesc(type);
+
+                    //Console.WriteLine("ktttt--type-----........" + type);
+                    //Console.WriteLine("ktttt--name-----........" + desc);
+
+                    var rowi = sheet.CreateRow(x);
+                    var cdesc = rowi.CreateCell(0);
+                    cdesc.SetCellValue(desc);
+
+                    var cType = rowi.CreateCell(1);
+                    cType.SetCellValue(type);
+
+                    var cnum = rowi.CreateCell(2);
+                    cnum.SetCellValue(num);
+
+                    x += 1;
+                }
+
+            }
+
+            TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1);
+            float curday = MathF.Floor((long)ts.TotalSeconds / 24 / 60 / 60);
+
+            string txtName = "指标累计信息表_" + "zone" + zoneid + "-day-" + curday;
+
+            FileStream file = new FileStream(@"F:\excel\" + txtName + ".xls", FileMode.CreateNew, FileAccess.Write);
+            workbook.Write(file);
+            file.Dispose();
+
+            Console.WriteLine("指标累计execl完成........");
+        }
+
+        public static string TargetDesc(string type)
+        {
+            string[] sList = type.Split('-');
+            var mem = Redis.Ins.GetDatabase(0);
+            string desc = "";
+            switch (sList[0])
+            {
+                case "registerUserNum":
+                    desc = "注册人数累计";
+                    break;
+                case "comNewGuideUserNum":
+                    desc = "完成新手引导人数累计";
+                    break;
+                case "unlockbuidId":
+                    string ctx = mem.HashGet(MemKey_Game.Build(), sList[1]);
+                    JObject ctxDic = JObject.Parse(ctx);
+                    string s = ctxDic["name"].ToString();
+                    desc = "累计解锁建筑-" + s + "的人数";
+                    break;
+                case "mainTaskId_ComUserNum"://主线任务id--完成人数
+                    desc = "完成主线任务id-" + sList[1] + "的人数";
+
+                    break;
+
+                case "shopTaskId_ComUserNum":
+                    desc = "完成悬赏任务id-" + sList[1] + "的人数";
+
+                    break;
+                case "shopTaskId_BuyUserNum":
+                    desc = "购买悬赏任务id-" + sList[1] + "的人数";
+
+                    break;
+                case "collegeTaskId_ComUserNum":
+                    desc = "完成学院任务id-" + sList[1] + "的人数";
+
+                    break;
+                case "collegeCouseId_UnlockUserNum":
+                    desc = "解锁学院课程id-" + sList[1] + "的人数";
+
+                    break;
+
+                case "dailyTaskId_ComUserNum":
+                    desc = "完成日常任务id-" + sList[1] + "的人数";
+
+                    break;
+                case "storyGateId_ComUserNum":
+                    desc = "完成剧情关卡id-" + sList[1] + "的人数";
+                    break;
+
+                case "storyGateId_BattleNum":
+                    desc = "剧情关卡id-" + sList[1] + "的挑战次数/通关次数";
+                    break;
+
+                case "HuanLingShiGateId_ComUserNum":
+                    desc = "完成副本唤灵师关卡id-" + sList[1] + "的人数";
+                    break;
+                case "HuanLingShiGateId_BattleNum":
+                    desc = "完成副本唤灵师关卡id-" + sList[1] + "的挑战次数/通关次数";
+                    break;
+                case "WeaponGateId_ComUserNum":
+                    desc = "完成副本武器关卡id-" + sList[1] + "的人数";
+                    break;
+                case "WeaponGateId_BattleNum":
+                    desc = "完成副本武器关卡id-" + sList[1] + "的挑战次数/通关次数";
+                    break;
+
+                case "YanLingGateId_ComUserNum":
+                    desc = "完成副本言灵关卡id-" + sList[1] + "的人数";
+                    break;
+                case "YanLingGateId_BattleNum":
+                    desc = "完成副本言灵关卡id-" + sList[1] + "的挑战次数/通关次数";
+                    break;
+                case "userlevel":
+                    desc = "玩家等级为" + sList[1] + "的人数";
+                    break;
+                case "newUserLotteryDraw_one":
+                    desc = "新手池抽卡单次抽奖的访问频率";
+                    break;
+                case "newUserLotteryDraw_ten":
+                    desc = "新手池抽卡十连抽的访问频率";
+                    break;
+                case "yanLingLotteryDraw_one":
+                    desc = "言灵活动祈愿奖池单次抽奖的访问频率";
+                    break;
+                case "yanLingLotteryDraw_ten":
+                    desc = "言灵活动祈愿奖池十连抽的访问频率";
+                    break;
+                case "weaponLotteryDraw_one":
+                    desc = "武器活动祈愿奖池单次抽奖的访问频率";
+                    break;
+                case "weaponLotteryDraw_ten":
+                    desc = "武器活动祈愿奖池十连抽的访问频率";
+                    break;
+
+                case "commonLotteryDraw_one":
+                    desc = "常驻祈愿奖池单次抽奖的访问频率";
+                    break;
+                case "commonLotteryDraw_ten":
+                    desc = "常驻祈愿奖池十连抽的访问频率";
+                    break;
+
+                case "HuanLingShiLevel_UserNum":
+                    desc = "唤灵师" + sList[1] + "等级为" + sList[2] + "的人数";
+                    break;
+                case "HuanLingShiId_UserNum":
+                    desc = "拥有唤灵师" + sList[1] + "的人数";
+                    break;
+
+                case "YanLingId_UserNum":
+                    desc = "拥有言灵" + sList[1] + "的人数";
+                    break;
+                case "YanLingIdLevel_UserNum":
+                    desc = "言灵" + sList[1] + "等级为" + sList[2] + "的人数";
+                    break;
+                case "WeaponId_UserNum":
+                    desc = "拥有武器" + sList[1] + "的人数";
+                    break;
+                case "WeaponIdLevel_UserNum":
+                    desc = "武器" + sList[1] + "等级为" + sList[2] + "的人数";
+                    break;
+
+            }
+
+
+            return desc;
+        }
+
+        public static string targetType(string t)
+        {
+            string type = "";
+            switch (t)
+            {
+                case "registerUserNum":
+                    type = "registerUserNum";
+                    break;
+                case "comNewGuideUserNum":
+                    type = "comNewGuideUserNum";
+                    break;
+                case "unlockbuidId":
+                    type = "unlockbuidId";
+                    break;
+                case "mainTaskId_ComUserNum"://主线任务id--完成人数
+                    type = "mainTask";
+
+                    break;
+
+                case "shopTaskId_ComUserNum":
+                    type = "shopTask";
+
+                    break;
+                case "shopTaskId_BuyUserNum":
+                    type = "shopTask";
+
+                    break;
+                case "collegeTaskId_ComUserNum":
+                    type = "collegeTask";
+                    break;
+                case "collegeCouseId_UnlockUserNum":
+                    type = "collegeTask";
+
+                    break;
+
+                case "dailyTaskId_ComUserNum":
+                    type = "dailyTask";
+
+                    break;
+                case "storyGateId_ComUserNum":
+                    type = "storyGate";
+                    break;
+
+                case "storyGateId_BattleNum":
+                    type = "storyGate";
+                    break;
+
+                case "HuanLingShiGateId_ComUserNum":
+                    type = "HuanLingShiGate";
+                    break;
+                case "HuanLingShiGateId_BattleNum":
+                    type = "HuanLingShiGate";
+                    break;
+                case "WeaponGateId_ComUserNum":
+                    type = "WeaponGate";
+                    break;
+                case "WeaponGateId_BattleNum":
+                    type = "WeaponGate";
+                    break;
+
+                case "YanLingGateId_ComUserNum":
+                    type = "YanLingGate";
+                    break;
+                case "YanLingGateId_BattleNum":
+                    type = "YanLingGate";
+                    break;
+                case "userlevel":
+                    type = "userlevel";
+                    break;
+                case "newUserLotteryDraw_one":
+                    type = "LotteryDraw";
+                    break;
+                case "newUserLotteryDraw_ten":
+                    type = "LotteryDraw";
+                    break;
+                case "yanLingLotteryDraw_one":
+                    type = "LotteryDraw";
+                    break;
+                case "yanLingLotteryDraw_ten":
+                    type = "LotteryDraw";
+                    break;
+                case "weaponLotteryDraw_one":
+                    type = "LotteryDraw";
+                    break;
+                case "weaponLotteryDraw_ten":
+                    type = "LotteryDraw";
+                    break;
+
+                case "commonLotteryDraw_one":
+                    type = "LotteryDraw";
+                    break;
+                case "commonLotteryDraw_ten":
+                    type = "LotteryDraw";
+                    break;
+
+                case "HuanLingShiLevel_UserNum":
+                    type = "HuanLingShi";
+                    break;
+                case "HuanLingShiId_UserNum":
+                    type = "HuanLingShi";
+                    break;
+
+                case "YanLingId_UserNum":
+                    type = "YanLing";
+                    break;
+                case "YanLingIdLevel_UserNum":
+                    type = "YanLing";
+                    break;
+                case "WeaponId_UserNum":
+                    type = "Weapon";
+                    break;
+                case "WeaponIdLevel_UserNum":
+                    type = "Weapon";
+                    break;
+
+            }
+
+            return type;
+        }
+
+
+
+    }
+}

+ 7 - 1
CSserver/csserver.sln

@@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataTransfer", "DataTransfe
 EndProject
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiDup", "MultiDup\MultiDup.csproj", "{25F90738-ECAE-40CC-883F-86A75E6C253B}"
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiDup", "MultiDup\MultiDup.csproj", "{25F90738-ECAE-40CC-883F-86A75E6C253B}"
 EndProject
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BattleRoom", "BattleRoom\BattleRoom.csproj", "{B5253393-934B-4481-B7E3-5B9F4715EC00}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BattleRoom", "BattleRoom\BattleRoom.csproj", "{B5253393-934B-4481-B7E3-5B9F4715EC00}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatisticsTransfer", "StatisticsTransfer\StatisticsTransfer.csproj", "{110B13DC-8B5F-4114-8B08-029D9EADF149}"
 EndProject
 EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -59,6 +61,10 @@ Global
 		{B5253393-934B-4481-B7E3-5B9F4715EC00}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{B5253393-934B-4481-B7E3-5B9F4715EC00}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{B5253393-934B-4481-B7E3-5B9F4715EC00}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{B5253393-934B-4481-B7E3-5B9F4715EC00}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{B5253393-934B-4481-B7E3-5B9F4715EC00}.Release|Any CPU.Build.0 = Release|Any CPU
 		{B5253393-934B-4481-B7E3-5B9F4715EC00}.Release|Any CPU.Build.0 = Release|Any CPU
+		{110B13DC-8B5F-4114-8B08-029D9EADF149}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{110B13DC-8B5F-4114-8B08-029D9EADF149}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{110B13DC-8B5F-4114-8B08-029D9EADF149}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{110B13DC-8B5F-4114-8B08-029D9EADF149}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE