CrazyIter_Bin 2 년 전
부모
커밋
4c68d5ce66

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/GroupList.cs

@@ -207,6 +207,8 @@ namespace TEAMModelOS.SDK.Models
         //补充毕业
         //0在校,1毕业 
         public int graduate { get; set; } = 0;
+        //所在名单集合
+        public List<string> groupListIds { get; set; } = new List<string>();
 
     }
     public class GroupListGrp

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/Attachment.cs

@@ -54,5 +54,6 @@ namespace TEAMModelOS.SDK.Models
         /// 创建者
         /// </summary>
         public long creator { get; set; }
+        public List<string> tag { get; set; }= new List<string>();
     }
 }

+ 59 - 2
TEAMModelOS/Controllers/Common/ArtController.cs

@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Options;
+using NUnit.Framework;
 using OpenXmlPowerTools;
 using System;
 using System.Collections.Generic;
@@ -419,15 +420,71 @@ namespace TEAMModelOS.Controllers.Common
                 if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 ArtEvaluation art = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ArtEvaluation>(id.GetString(), new PartitionKey($"Art-{code}"));
+             
                 if (art != null)
                 {
-                    List<GroupListDto> groups = await GroupListService.GetGroupListByListids(client, _dingDing, art.classes, art.school);
+                    (List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids(  _coreAPIHttpService, client, _dingDing, art.classes, art.school);
                     var classes = art.classes.Select(c => new
                     {
                         id = c,
                         groups.Where(g => g.id.Equals(c)).FirstOrDefault().name
                     });
-                    return Ok(new { art, classes, code = 200 });
+                    rmembers.ForEach(x =>
+                    {
+                        groups.ForEach(z =>
+                        {
+                            if (z.members.Exists(y => y.id.Equals(x.id) && y.type == x.type))
+                            {
+                                x.groupListIds.Add(z.id);
+                            }
+                        });
+
+                    });
+                    var students=  rmembers.Select(z => new StudentArtResult {
+                        studentId = z.id,
+                        studentName = z.name,
+                        userType = z.type,
+                        classIds = z.groupListIds,
+                        school = z.schoolId,
+                        picture = z.picture,
+                        artId = $"{id}",
+                        id=$"{z.schoolId}-{z.id}",
+                        code=$"ArtResult-{id}",
+                        pk= "ArtResult",
+                        ttl=-1,
+                    }).ToList();
+                    if (students.Any()) {
+                        string query = $" select c.id from c where c.id in({string.Join(",", students.Select(x => $"'{x.id}'"))}) ";
+                        List<string> list = new List<string>();
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<string>
+                             (queryText: query, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{id}") }))
+                        {
+                            list.Add(item);
+                        }
+                        students.RemoveAll(x => list.Contains(x.id));
+                        students.ForEach(x => {
+                            art.settings.ForEach(a => {
+                                a.task.ForEach(z => {
+                                    ArtQuotaResult quotaResult = new ArtQuotaResult
+                                    {
+                                        taskId=z.acId,
+                                        subjectId=z.subject,
+                                        quotaId=a.id,
+                                        quotaType=z.type.Value,
+                                    };
+                                    x.results.Add(quotaResult);
+                                });
+                            });
+                        });
+                        if (students.Any()) {
+                            List<Task<ItemResponse<StudentArtResult>>> responses = new List<Task<ItemResponse<StudentArtResult>>>(); 
+                            students.ForEach(  z => {
+                                responses.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).CreateItemAsync(z, new PartitionKey(z.code)));
+                            });
+                            await Task.WhenAll(responses);
+                        }
+                    }
+                    return Ok(new { art, classes, code = 200  });
                 }
                 else
                 {

+ 21 - 0
TEAMModelOS/Controllers/School/ArtReviewController.cs

@@ -68,6 +68,27 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [AuthToken(Roles = "teacher,admin")]
+        [HttpPost("gen-pdf")]
+        //[Authorize(Roles = "IES")]
+        public async Task<IActionResult> GenPDF(JsonElement request) {
+            if (!request.TryGetProperty("opt", out JsonElement _opt))
+            {
+                return BadRequest();
+            }
+            if (!request.TryGetProperty("artId", out JsonElement _artId))
+            {
+                return BadRequest();
+            }
+            var (userid, name, _, school) = HttpContext.GetAuthTokenInfo();
+            return Ok();
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "teacher,admin")]
         [HttpPost("review")]
         //[Authorize(Roles = "IES")]
         public async Task<IActionResult> Review(JsonElement request) {