|
@@ -105,7 +105,7 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
List<IdInfo> idInfos = new();
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"School").GetItemQueryIterator<IdInfo>(queryText: "select c.id,c.name,c.picture from c",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<IdInfo>(queryText: "select c.id,c.name,c.picture from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{scId}") }))
|
|
|
{
|
|
|
idInfos.Add(item);
|
|
|
}
|
|
@@ -120,7 +120,7 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
/// <returns></returns>
|
|
|
[AuthToken(Roles = "admin,rdc,assist,sales")]
|
|
|
[HttpPost("push-info")]
|
|
|
- public async Task<IActionResult> PushNotion(JsonElement jsonElement)
|
|
|
+ public async Task<IActionResult> PushNotion(JsonElement jsonElement)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -135,7 +135,7 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
jsonElement.TryGetProperty("schoolIds", out JsonElement _schoolIds);
|
|
|
jsonElement.TryGetProperty("areaIds", out JsonElement _areaIds);
|
|
|
if (!jsonElement.TryGetProperty("crowdType", out JsonElement _crowdType)) return BadRequest();
|
|
|
- if(!jsonElement.TryGetProperty("sendTime", out JsonElement sendTime)) return BadRequest();
|
|
|
+ if (!jsonElement.TryGetProperty("sendTime", out JsonElement sendTime)) return BadRequest();
|
|
|
jsonElement.TryGetProperty("source", out JsonElement source);
|
|
|
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
@@ -143,38 +143,40 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
|
|
|
List<IdNameCode> idNameCodes = new();
|
|
|
BINotice bINotice = new();
|
|
|
- List<string> tmdIds = new();
|
|
|
- List<string> schoolIds = new();
|
|
|
- List<string> areaIds = new();
|
|
|
+ List<CrowdInfo> tmdIds = new();
|
|
|
+ List<CrowdInfo> schoolIds = new();
|
|
|
+ List<CrowdInfo> areaIds = new();
|
|
|
+
|
|
|
+ List<string> tempScIds = new();
|
|
|
|
|
|
//if (!string.IsNullOrEmpty($"{sendTime}"))
|
|
|
// dateTime = DateTimeOffset.Parse($"{sendTime}");
|
|
|
if (string.IsNullOrEmpty($"{_tmdIds}") && string.IsNullOrEmpty($"{_schoolIds}") && string.IsNullOrEmpty($"{_areaIds}"))
|
|
|
return Ok(new { state = RespondCode.ParamsError, msg = "发送人群不能为空" });
|
|
|
if (!string.IsNullOrEmpty($"{_tmdIds}"))
|
|
|
- tmdIds = _tmdIds.ToObject<List<string>>();
|
|
|
+ tmdIds = _tmdIds.ToObject<List<CrowdInfo>>();
|
|
|
if (!string.IsNullOrEmpty($"{_schoolIds}"))
|
|
|
- schoolIds = _schoolIds.ToObject<List<string>>();
|
|
|
+ schoolIds = _schoolIds.ToObject<List<CrowdInfo>>();
|
|
|
if (!string.IsNullOrEmpty($"{_areaIds}"))
|
|
|
- areaIds = _areaIds.ToObject<List<string>>();
|
|
|
+ areaIds = _areaIds.ToObject<List<CrowdInfo>>();
|
|
|
|
|
|
Crowd crowd = new()
|
|
|
{
|
|
|
- tmdIds = tmdIds.Count > 0 ? tmdIds : new List<string>(),
|
|
|
- schoolIds = schoolIds.Count > 0 ? schoolIds : new List<string>(),
|
|
|
- areaIds = areaIds.Count > 0 ? areaIds : new List<string>(),
|
|
|
+ tmdIds = tmdIds.Count > 0 ? tmdIds : new List<CrowdInfo>(),
|
|
|
+ schoolIds = schoolIds.Count > 0 ? schoolIds : new List<CrowdInfo>(),
|
|
|
+ areaIds = areaIds.Count > 0 ? areaIds : new List<CrowdInfo>(),
|
|
|
types = _crowdType.ToObject<List<string>>()
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
if (tmdIds.Count > 0)
|
|
|
{
|
|
|
StringBuilder tchSql = new($"select c.id, c.name,c.code,c.picture,c.nickname from c ");
|
|
|
if (tmdIds.Count > 0)
|
|
|
{
|
|
|
- tchSql.Append(BICommonWay.ManyScSql(" where c.id ", tmdIds));
|
|
|
+ tchSql.Append(BICommonWay.ManyScSql(" where c.id ", tmdIds.Select(s => s.id).ToList()));
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<IdNameCode>(queryText: tchSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
- var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item)).ToList();
|
|
|
+ var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item.id)).ToList();
|
|
|
if (tempId.Count == 0)
|
|
|
idNameCodes.Add(item);
|
|
|
}
|
|
@@ -186,12 +188,12 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
StringBuilder scAreaSql = new($"select value(c.id) from c");
|
|
|
if (schoolIds.Count > 0)
|
|
|
{
|
|
|
- scAreaSql.Append(BICommonWay.ManyScSql(" where c.areaId", areaIds));
|
|
|
+ scAreaSql.Append(BICommonWay.ManyScSql(" where c.areaId", areaIds.Select(s => s.id).ToList()));
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<string>(queryText: scAreaSql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
var tempScId = schoolIds.FindAll(fa => fa.Equals(item)).ToList();
|
|
|
if (tempScId.Count == 0)
|
|
|
- schoolIds.Add(item);
|
|
|
+ tempScIds.Add(item);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -201,10 +203,10 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
StringBuilder scTchSql = new($"select c.id, c.name, c.picture,c.nickname from c where c.pk='Teacher'");
|
|
|
if (schoolIds.Count > 0)
|
|
|
{
|
|
|
- scTchSql.Append(BICommonWay.ManyScSql(" and c.code", schoolIds, $"Teacher-"));
|
|
|
+ scTchSql.Append(BICommonWay.ManyScSql(" and c.code", schoolIds.Select(s => s.id).ToList(), $"Teacher-"));
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<IdNameCode>(queryText: scTchSql.ToString(), requestOptions: new QueryRequestOptions() { }))
|
|
|
{
|
|
|
- var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item)).ToList();
|
|
|
+ var tempId = idNameCodes.FindAll(fa => fa.id.Equals(item.id)).ToList();
|
|
|
if (tempId.Count == 0)
|
|
|
idNameCodes.Add(item);
|
|
|
}
|
|
@@ -221,7 +223,7 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
theme = $"{theme}",
|
|
|
content = $"{content}",
|
|
|
crowd = crowd,
|
|
|
- crowdIds = tmdIds,
|
|
|
+ crowdIds = idNameCodes.Select(s => s.id).ToList(),
|
|
|
createId = _tmdId,
|
|
|
sendTime = sendTime.GetInt64(),//发布时间待解决
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
@@ -236,7 +238,7 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- _ = _dingDing.SendBotMsg($"BI, notion/PushNotion() \n{ex.Message}\n{ex.StackTrace}\n", GroupNames.成都开发測試群組);
|
|
|
+ //_ = _dingDing.SendBotMsg($"BI, notion/PushNotion() \n{ex.Message}\n{ex.StackTrace}\n", GroupNames.成都开发測試群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
}
|
|
@@ -246,8 +248,8 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
/// </summary>
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
- [AuthToken(Roles = "admin,rdc,assist,sales")]
|
|
|
[HttpPost("get-infos")]
|
|
|
+ [AuthToken(Roles = "admin,rdc,assist,sales")]
|
|
|
public async Task<IActionResult> GetInfos(JsonElement jsonElement)
|
|
|
{
|
|
|
jsonElement.TryGetProperty("id", out JsonElement id);
|
|
@@ -255,9 +257,9 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
List<BINotice> bINotices = new();
|
|
|
StringBuilder sql = new("select value(c) from c");
|
|
|
- if (!string.IsNullOrEmpty($"{id}"))
|
|
|
+ if (!string.IsNullOrEmpty($"{id}"))
|
|
|
sql.Append($" where c.id='{id}'");
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS,"Common").GetItemQueryIterator<BINotice>(queryText:sql.ToString(),requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BINotice") }))
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<BINotice>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BINotice") }))
|
|
|
{
|
|
|
bINotices.Add(item);
|
|
|
}
|