|
@@ -5,6 +5,7 @@ using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using FastJSON;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
+using IP2Region.Net.Abstractions;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Cors;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
@@ -38,6 +39,7 @@ using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
|
|
|
+using TEAMModelOS.SDK.IP2Region;
|
|
|
using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
|
|
|
using Top.Api;
|
|
|
|
|
@@ -55,9 +57,9 @@ namespace TEAMModelOS.Controllers
|
|
|
private readonly IConfiguration _configuration;
|
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
|
private readonly AzureRedisFactory _azureRedis;
|
|
|
- private readonly IPSearcher _ipSearcher;
|
|
|
+ private readonly ISearcher _ipSearcher;
|
|
|
private readonly Option _option;
|
|
|
- public BillController(IHttpClientFactory httpClient, IConfiguration configuration, AzureStorageFactory azureStorage, IPSearcher searcher, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
+ public BillController(IHttpClientFactory httpClient, IConfiguration configuration, AzureStorageFactory azureStorage, ISearcher searcher, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
{
|
|
|
_httpClient = httpClient;
|
|
|
_configuration = configuration;
|
|
@@ -77,6 +79,7 @@ namespace TEAMModelOS.Controllers
|
|
|
[RequestSizeLimit(102_400_000_00)] //最大10000m左右
|
|
|
public async Task<IActionResult> ReportApi(JsonElement json)
|
|
|
{
|
|
|
+ var reg = _ipSearcher.SearchIp(json.GetProperty("ip").GetString());
|
|
|
var untyped = new JsonParser().Parse(json.GetRawText());
|
|
|
var selection = new JsonPathSelection(untyped);
|
|
|
{
|
|
@@ -108,7 +111,7 @@ namespace TEAMModelOS.Controllers
|
|
|
else
|
|
|
{
|
|
|
List<ApiVist> vistsDay = new List<ApiVist>();
|
|
|
- List<(string uuid, List<string> tmdid, List<string> school)> uuidInfos = new List<(string uuid, List<string> tmdid, List<string> school)>();
|
|
|
+ List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfos = new List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
|
|
|
List<string> files = await _azureStorage.GetBlobContainerClient("0-service-log").List($"http-log/{time}");
|
|
|
foreach (var file in files)
|
|
|
{
|
|
@@ -122,13 +125,16 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
BlobDownloadResult result = await _azureStorage.GetBlobContainerClient("0-service-log").GetBlobClient($"http-log/{time}/{hour}.json").DownloadContentAsync();
|
|
|
var httpLogs = result.Content.ToObjectFromJson<List<HttpLog>>();
|
|
|
- (List<ApiVist> vists, List<(string uuid, List<string> tmdid, List<string> school)> uuidInfo) = Convert(httpLogs);
|
|
|
+ (List<ApiVist> vists, List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo) = await Convert(httpLogs);
|
|
|
vistsDay.AddRange(vists);
|
|
|
uuidInfos.AddRange(uuidInfo);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ vistsDay.FindAll(x => x.path.Contains("common/exam/upsert-record"));
|
|
|
+
|
|
|
List<(string tmd, bool exists, string scope)> tmdexists = new List<(string tmd, bool exists, string scope)>();
|
|
|
List<(string sch, bool exists)> schexists = new List<(string sch, bool exists)>();
|
|
|
var tmds = uuidInfos.SelectMany(x => x.tmdid).ToHashSet();
|
|
@@ -193,13 +199,16 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return Ok();
|
|
|
+ return Ok(reg);
|
|
|
}
|
|
|
|
|
|
- public (List<ApiVist> vists, List<(string uuid, List<string> tmdid, List<string> school)> uuidInfo) Convert(List<HttpLog> logs)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<(List<ApiVist> vists, List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo)> Convert(List<HttpLog> logs)
|
|
|
{
|
|
|
List<ApiVist> vists = new List<ApiVist>();
|
|
|
- List<(string uuid, List<string> tmdid, List<string> school)> uuidInfo = new List<(string uuid, List<string> tmdid, List<string> school)>();
|
|
|
+ List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)> uuidInfo = new List<(string uuid, HttpLog httpLog, List<string> tmdid, List<string> school)>();
|
|
|
foreach (HttpLog log in logs)
|
|
|
{
|
|
|
string uuid = Guid.NewGuid().ToString();
|
|
@@ -211,14 +220,14 @@ namespace TEAMModelOS.Controllers
|
|
|
var untyped = new JsonParser().Parse(log.param.GetRawText());
|
|
|
var selection = new JsonPathSelection(untyped);
|
|
|
string path = "$..[id_token,idToken,idtoken,tmdid,id,teacherId,teacher,tid,tId,userid,userId,code,studentId,student,studentid]";
|
|
|
-
|
|
|
+
|
|
|
var nodes_path = selection.SelectNodes(path);
|
|
|
foreach (var node in nodes_path)
|
|
|
{
|
|
|
// 只获取是字符串的
|
|
|
if (node.Value is string)
|
|
|
{
|
|
|
- switch (true)
|
|
|
+ switch (true)
|
|
|
{
|
|
|
case bool when node.Path.Contains("id_token")||node.Path.Contains("idToken")||node.Path.Contains("idtoken"):
|
|
|
{
|
|
@@ -266,7 +275,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -484,9 +493,9 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -572,77 +581,268 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
|
|
|
|
|
|
- uuidInfo.Add((uuid, useridMatch, schoolMatch));
|
|
|
+ uuidInfo.Add((uuid, log, useridMatch, schoolMatch));
|
|
|
vists.Add(vist);
|
|
|
+ //处理 client
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrWhiteSpace(log.client))
|
|
|
+ {
|
|
|
+ if (log.client.Equals("IES", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="ies5";
|
|
|
+ }
|
|
|
+ if (log.client.Equals("AClassONE", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="aclassone";
|
|
|
+ }
|
|
|
+ if (log.client.Equals("BB", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="habb";
|
|
|
+ }
|
|
|
+ if (log.client.Equals("HiTool", StringComparison.OrdinalIgnoreCase) ||log.client.Equals("HiTools", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="hiscan";
|
|
|
+ }
|
|
|
+ if (log.client.Equals("HiTA", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="hita";
|
|
|
+ }
|
|
|
+ if (log.client.Equals("HiTeachCC", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="hiteachcc";
|
|
|
+ }
|
|
|
+ if (log.client.Equals("HiTeach", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="hiteach";
|
|
|
+ }
|
|
|
+ if (log.client.Equals("Open", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ vist.client="open";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//补全站点
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("teammodelos-yx.chinacloudsites.cn")||log.host.Equals("teammodelos.chinacloudsites.cn")
|
|
|
- ||log.host.Equals("yx.teammodel.cn")||log.host.Equals("scyx.teammodel.cn") ||log.host.Equals("jinniu.teammodel.cn")))
|
|
|
+ ||log.host.Equals("yx.teammodel.cn")))
|
|
|
{
|
|
|
+ log.host="IES-正式站";
|
|
|
log.host="www.teammodel.cn";
|
|
|
+ vist.client="ies5";
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
+ &&(log.host.Equals("scyx.teammodel.cn") ||log.host.Equals("jinniu.teammodel.cn")))
|
|
|
+ {
|
|
|
+ log.host="研修2.0-正式站";
|
|
|
+ log.host="scyx.teammodel.cn";
|
|
|
+ vist.client="ability";
|
|
|
}
|
|
|
+ if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
+ &&(log.host.Equals("open.teammodel.cn")))
|
|
|
+ {
|
|
|
+ log.host="开放平台-正式站";
|
|
|
+ log.host="open.teammodel.cn";
|
|
|
+ vist.client="open";
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
+ &&(log.host.Equals("open-test.teammodel.cn") ||log.host.Equals("zhiyin-test.teammodel.cn")))
|
|
|
+ {
|
|
|
+ log.host="开放平台-测试站";
|
|
|
+ log.host="open-test.teammodel.cn";
|
|
|
+ vist.client="open";
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("teammodelos-rc.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="IES-RC站";
|
|
|
log.host="rc.teammodel.cn";
|
|
|
+ vist.client="ies5";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
- &&(log.host.Equals("teammodelos-test.chinacloudsites.cn") || log.host.Equals("zhiyin-test.teammodel.cn")))
|
|
|
+ &&(log.host.Equals("teammodelos-test.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="IES-测试站";
|
|
|
log.host="test.teammodel.cn";
|
|
|
+ vist.client="ies5";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("teammodelbi-test.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="BI-测试站";
|
|
|
log.host="bitest.teammodel.cn";
|
|
|
+ vist.client="bi";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("teammodelbi.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="BI-正式站";
|
|
|
log.host="bi.teammodel.cn";
|
|
|
+ vist.client="bi";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("teamcontest.chinacloudsites.cn")))
|
|
|
{
|
|
|
- log.host="bi.teammodel.cn";
|
|
|
+ log.host="赛课-正式站";
|
|
|
+ log.host="contest.teammodel.cn";
|
|
|
+ vist.client="contest";
|
|
|
+
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("contest.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="赛课-正式站";
|
|
|
log.host="contest.teammodel.cn";
|
|
|
+ vist.client="contest";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("contest-test.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="赛课-测试站";
|
|
|
log.host="contest-test.teammodel.cn";
|
|
|
+ vist.client="contest";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("hiteachcc.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="CC-正式站";
|
|
|
log.host="hiteachcc.teammodel.cn";
|
|
|
+ vist.client="hiteachcc";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("appraisal.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="评价-正式站";
|
|
|
log.host="appraisal.teammodel.cn";
|
|
|
+ vist.client="appraisal";
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(log.host)
|
|
|
&&(log.host.Equals("appraisal-test.chinacloudsites.cn")))
|
|
|
{
|
|
|
+ log.host="评价-测试站";
|
|
|
log.host="appraisal-test.teammodel.cn";
|
|
|
+ vist.client="appraisal";
|
|
|
+ }
|
|
|
+ if (log.host.Equals("localhost") && log.p.Equals("os"))
|
|
|
+ {
|
|
|
+ log.host="IES-测试站";
|
|
|
+ log.host="test.teammodel.cn";
|
|
|
+ vist.client="ies5";
|
|
|
+ }
|
|
|
+ else if (log.host.Equals("localhost") && (log.p.Equals("bi")))
|
|
|
+ {
|
|
|
+ log.host="BI-测试站";
|
|
|
+ log.host="bitest.teammodel.cn";
|
|
|
+ vist.client="bi";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (log.host.Equals("localhost") && log.p.Equals("os"))
|
|
|
+ //补全产品端
|
|
|
{
|
|
|
- log.host="test.teammodel.cn";
|
|
|
+ //研修2.0
|
|
|
+ if (log.path.Contains("research") || log.path.Contains("study") || log.path.Contains("standard-file"))
|
|
|
+ {
|
|
|
+ vist.client="ability";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (log.path.StartsWith("/activity"))
|
|
|
+ {
|
|
|
+ vist.client="contest";
|
|
|
+ }
|
|
|
+ //小程序
|
|
|
+ if (log.path.Contains("aclassone"))
|
|
|
+ {
|
|
|
+ vist.client="aclassone";
|
|
|
+ }
|
|
|
+ // /// <summary>
|
|
|
+ /// ExamInfo qamode 書面問答類型 0:書面問答 1:紙本測驗 2:艺术评测
|
|
|
+ /// </summary>
|
|
|
+ //艺术评测
|
|
|
+ if (log.path.Contains("art") ||log.path.Contains("aclassone/find-children-activity") ||log.path.Contains("aclassone/find-teacher-activity") ||log.path.Contains("aclassone/find-summary-activity") ||log.path.Contains("aclassone/upload-all") ||log.path.Contains("aclassone/delete"))
|
|
|
+ {
|
|
|
+ vist.client="art";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (log.path.Contains("habb"))
|
|
|
+ {
|
|
|
+ vist.client="habb";
|
|
|
+ }
|
|
|
+ //阅卷客户端
|
|
|
+ if (log.path.Contains("hiscan"))
|
|
|
+ {
|
|
|
+ vist.client="hiscan";
|
|
|
+ }
|
|
|
+ if (log.path.Contains("hita"))
|
|
|
+ {
|
|
|
+ vist.client="hita";
|
|
|
+ }
|
|
|
+ if (log.path.Contains("hiteachcc"))
|
|
|
+ {
|
|
|
+ vist.client="hiteachcc";
|
|
|
+ }
|
|
|
+ if (log.path.Contains("sokrate"))
|
|
|
+ {
|
|
|
+ vist.client="sokrate";
|
|
|
+ }
|
|
|
+ if (log.path.Contains("sokrate") || log.path.Contains("score"))
|
|
|
+ {
|
|
|
+ vist.client="sokrate";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (log.path.Contains("hiteach"))
|
|
|
+ {
|
|
|
+ vist.client="hiteach";
|
|
|
+ }
|
|
|
+ ///IES开放平台
|
|
|
+ if (log.path.Contains("business") || log.path.Contains("biz") || log.path.Contains("openapi-config") || log.path.Contains("open-api"))
|
|
|
+ {
|
|
|
+ vist.client="open";
|
|
|
+ }
|
|
|
+ //从token的role 能否获取 开放平台
|
|
|
+ //单点登录及第三方接口
|
|
|
+ if (log.path.Contains("lepei") || log.path.Contains("sc/") || log.path.Contains("/sso") || log.path.Contains("sc-init") || log.path.Contains("data-push") || log.path.Contains("xkw")|| log.path.Contains("tianbo")
|
|
|
+ || log.path.Contains("oauth/check-bind")|| log.path.Contains("dingding") || log.path.Contains("wechat")
|
|
|
+ )
|
|
|
+ {
|
|
|
+ vist.client="sso-third";
|
|
|
+ }
|
|
|
}
|
|
|
- else if (log.host.Equals("localhost") && ( log.p.Equals("bi")))
|
|
|
+
|
|
|
+ //处理IP转地区
|
|
|
+ vist.region=_ipSearcher.SearchIp(vist.ip);
|
|
|
+ if (!string.IsNullOrWhiteSpace(vist.region))
|
|
|
{
|
|
|
- log.host="bitest.teammodel.cn";
|
|
|
+ var regions = vist.region.Split("·");
|
|
|
+ if (regions.Length==4)
|
|
|
+ {
|
|
|
+ vist.area= regions[0];
|
|
|
+ vist.province = regions[1];
|
|
|
+ vist.city = regions[2];
|
|
|
+ }
|
|
|
+ if (regions.Length==3)
|
|
|
+ {
|
|
|
+ vist.area= regions[0];
|
|
|
+ vist.province = regions[1];
|
|
|
+ }
|
|
|
+ if (regions.Length==2)
|
|
|
+ {
|
|
|
+ vist.area= regions[0];
|
|
|
+ vist.province = regions[1];
|
|
|
+ }
|
|
|
+ if (regions.Length==1)
|
|
|
+ {
|
|
|
+ vist.area= regions[0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理地区转经纬度
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
vist.host= log.host;
|
|
|
+ vist.hostName=log.hostName;
|
|
|
}
|
|
|
return (vists, uuidInfo);
|
|
|
}
|
|
@@ -1326,11 +1526,16 @@ namespace TEAMModelOS.Controllers
|
|
|
public string tname { get; set; }
|
|
|
public string school { get; set; }
|
|
|
public string ip { get; set; }
|
|
|
+ public string region { get; set; }
|
|
|
+ public string area { get; set; }
|
|
|
+ public string province { get; set; }
|
|
|
+ public string city { get; set; }
|
|
|
public long time { get; set; }
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
public string host { get; set; }
|
|
|
+ public string hostName = "其他";
|
|
|
/// <summary>
|
|
|
/// tokenid
|
|
|
/// </summary>
|
|
@@ -1342,6 +1547,7 @@ namespace TEAMModelOS.Controllers
|
|
|
public string ip { get; set; }
|
|
|
public long time { get; set; }
|
|
|
public string host { get; set; }
|
|
|
+ public string hostName = "其他";
|
|
|
public string tid { get; set; }
|
|
|
public string path { get; set; }
|
|
|
public string client { get; set; }
|