|
@@ -66,6 +66,8 @@ using WebSocketSharp;
|
|
|
using System.Security.Policy;
|
|
|
using Azure.Messaging.ServiceBus.Administration;
|
|
|
using static TEAMModelOS.SDK.CoreAPIHttpService;
|
|
|
+using System.Xml;
|
|
|
+using System.Drawing.Printing;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BITest
|
|
|
{
|
|
@@ -2002,6 +2004,47 @@ namespace TEAMModelBI.Controllers.BITest
|
|
|
return Ok(new { state = 200, responseMessage });
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 比對統購活動產品的TMID名單
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("compare-purchaseSchool")]
|
|
|
+ public async Task<IActionResult> ComparePurchaseSchoolData(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ var cosmosClientCSV2 = _azureCosmos.GetCosmosClient(name: "CoreServiceV2");
|
|
|
+ List<PurchaseSchoolSeats> result = new List<PurchaseSchoolSeats>();
|
|
|
+ //STEP1 取得所有purchaseSchool
|
|
|
+ List<PurchaseSchoolSeats> data = new List<PurchaseSchoolSeats>();
|
|
|
+ string sqlText = "SELECT * FROM c ";
|
|
|
+ await foreach (var item in cosmosClientCSV2.GetContainer("Habb", "Auth").GetItemQueryIteratorSql<PurchaseSchoolSeats>(queryText: sqlText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"purchaseSchool") }))
|
|
|
+ {
|
|
|
+ data.Add(item);
|
|
|
+ }
|
|
|
+ //STEP2 比對相同學校 不同產品的 tmids,有差異的列出來
|
|
|
+ List<string> resultIds = new List<string>();
|
|
|
+ foreach(PurchaseSchoolSeats dataRow in data)
|
|
|
+ {
|
|
|
+ PurchaseSchoolSeats difData = data.Where(d => d.shortCode.Equals(dataRow.shortCode) && !d.tmids.Count.Equals(dataRow.tmids.Count)).FirstOrDefault();
|
|
|
+ if(difData != null)
|
|
|
+ {
|
|
|
+ if (!resultIds.Contains(dataRow.id))
|
|
|
+ {
|
|
|
+ result.Add(dataRow);
|
|
|
+ resultIds.Add(dataRow.id);
|
|
|
+ }
|
|
|
+ if (!resultIds.Contains(difData.id))
|
|
|
+ {
|
|
|
+ result.Add(difData);
|
|
|
+ resultIds.Add(difData.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { state = 200, result });
|
|
|
+ }
|
|
|
+
|
|
|
public class linqTest
|
|
|
{
|
|
|
public string id { get; set; }
|