From 8e9d78dcc4da8f1b28cdaff1cb6a46241a147afc Mon Sep 17 00:00:00 2001 From: "zhouj1203@hotmail.com" Date: Wed, 14 Aug 2024 14:38:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=89=BA=E6=9C=AF=E8=AF=84=E6=B5=8B=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/ArtController.java | 41 +++++++++ .../controller/admin/service/ArtService.java | 11 +++ .../admin/service/impl/ArtServiceImpl.java | 60 ++++++++++++ .../model/dto/admin/art/ArtFindDto.java | 21 +++++ .../cn/teammodel/model/entity/common/Art.java | 91 +++++++++++++++++++ .../model/vo/admin/ArtElementsVo.java | 34 +++++++ .../teammodel/repository/ArtRepository.java | 25 +++++ 7 files changed, 283 insertions(+) create mode 100644 src/main/java/cn/teammodel/controller/admin/controller/ArtController.java create mode 100644 src/main/java/cn/teammodel/controller/admin/service/ArtService.java create mode 100644 src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java create mode 100644 src/main/java/cn/teammodel/model/dto/admin/art/ArtFindDto.java create mode 100644 src/main/java/cn/teammodel/model/entity/common/Art.java create mode 100644 src/main/java/cn/teammodel/model/vo/admin/ArtElementsVo.java create mode 100644 src/main/java/cn/teammodel/repository/ArtRepository.java diff --git a/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java b/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java new file mode 100644 index 0000000..7d588f0 --- /dev/null +++ b/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java @@ -0,0 +1,41 @@ +package cn.teammodel.controller.admin.controller; + +import cn.teammodel.common.R; +import cn.teammodel.controller.admin.service.AdminIndexDutyService; +import cn.teammodel.controller.admin.service.ArtService; +import cn.teammodel.model.dto.admin.appraise.TimeRangeDto; +import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.dto.admin.weekduty.AdminFindDutyRecordDto; +import cn.teammodel.model.dto.weekDuty.LessonRecordDto; +import cn.teammodel.model.vo.admin.ArtElementsVo; +import cn.teammodel.model.vo.admin.DutyIndexData; +import cn.teammodel.model.vo.admin.DutyNodeRankVo; +import cn.teammodel.model.vo.admin.DutyRankPo; +import cn.teammodel.model.vo.weekDuty.DutyRecordVo; +import cn.teammodel.service.DutyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("admin/art") +@Api(tags = "管理员端-艺术评测") +public class ArtController { + + @Resource + private ArtService ArtService; + + @PostMapping("getArtList") + @ApiOperation("获取当前学校艺术评测列表") + public R> findRecords(@Valid @RequestBody ArtFindDto artFindDto) { + List res = ArtService.getArtList(artFindDto); + return R.success(res); + } + +} diff --git a/src/main/java/cn/teammodel/controller/admin/service/ArtService.java b/src/main/java/cn/teammodel/controller/admin/service/ArtService.java new file mode 100644 index 0000000..9301dae --- /dev/null +++ b/src/main/java/cn/teammodel/controller/admin/service/ArtService.java @@ -0,0 +1,11 @@ +package cn.teammodel.controller.admin.service; + +import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.vo.admin.ArtElementsVo; + +import java.util.List; +import java.util.Map; + +public interface ArtService { + List getArtList(ArtFindDto artFindDto); +} diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java new file mode 100644 index 0000000..8856827 --- /dev/null +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java @@ -0,0 +1,60 @@ +package cn.teammodel.controller.admin.service.impl; + +import cn.teammodel.common.PK; +import cn.teammodel.controller.admin.service.ArtService; +import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.entity.school.ClassInfo; +import cn.teammodel.model.vo.admin.ArtElementsVo; +import cn.teammodel.repository.ArtRepository; +import cn.teammodel.repository.ClassRepository; +import cn.teammodel.repository.StudentRepository; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +@Service +public class ArtServiceImpl implements ArtService { + @Resource + private ArtRepository artRepository; + @Resource + private ClassRepository classRepository; + @Resource + private StudentRepository studentRepository; + @Override + public List getArtList(ArtFindDto artFindDto) { + List artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode()); + List classIds = artElementsVos.stream() + .map(ArtElementsVo::getClasses) // 正确的方法引用 + .flatMap(List::stream) // 将内部列表扁平化 + .collect(Collectors.toList()); + + List classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds); + try { + for (ArtElementsVo artElementsVo : artElementsVos) { + List classes1 = artElementsVo.getClasses(); + int stuInClassCount = 0; + for(String classId : classes1) { + stuInClassCount += studentRepository.countByClassIdAndCode(classId, String.format(PK.STUDENT, artFindDto.getCode())); + ArtElementsVo.ClassInfos classInfos = new ArtElementsVo.ClassInfos(); + Optional className = classes.stream() + .filter(classInfo -> classInfo.getId().equals(classId)) + .map(ClassInfo::getName) + .findFirst(); + classInfos.setId(classId); + classInfos.setName(className.orElse("No Class Name")); + artElementsVo.addClassesInfos(classInfos); + } + artElementsVo.setCount(stuInClassCount); + + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return artElementsVos; + } +} diff --git a/src/main/java/cn/teammodel/model/dto/admin/art/ArtFindDto.java b/src/main/java/cn/teammodel/model/dto/admin/art/ArtFindDto.java new file mode 100644 index 0000000..97f1dfc --- /dev/null +++ b/src/main/java/cn/teammodel/model/dto/admin/art/ArtFindDto.java @@ -0,0 +1,21 @@ +package cn.teammodel.model.dto.admin.art; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class ArtFindDto +{ + @ApiModelProperty("学校编码") + private String code; + @ApiModelProperty("学段ID") + private String periodId; + @ApiModelProperty("学段类型") + private String periodType; + @ApiModelProperty("开始时间") + private Long startTime; + @ApiModelProperty("结束时间") + private Long endTime; +} diff --git a/src/main/java/cn/teammodel/model/entity/common/Art.java b/src/main/java/cn/teammodel/model/entity/common/Art.java new file mode 100644 index 0000000..637530f --- /dev/null +++ b/src/main/java/cn/teammodel/model/entity/common/Art.java @@ -0,0 +1,91 @@ +package cn.teammodel.model.entity.common; + +import cn.teammodel.model.entity.BaseItem; +import com.azure.spring.data.cosmos.core.mapping.Container; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@EqualsAndHashCode(callSuper = true) +@Container(containerName = "Common") +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Art extends BaseItem { + private String name; + private String school; + public List settings; + public String creatorId; + public String createTime; + public String updateTime; + public int type; + public List classes; + public List stuLists; + public List tchLists; + public List sIds; + public String progress; + public String scope; + public int status; + public long size; + public String owner; + public String areaId; + public String pId; + public String presenter; + public String topic; + public long startTime; + public long endTime; + public long uploadSTime; + public long uploadETime; + public String uploadProgress; + public String address; + public String pk; + public String desc; + public String img; + public int publish; + public List subjects; + public ArtPeriod period; + public String periodType; + public List lost; + public int pass; + public List miss; + public List zymusicstds; + public static class Acs { + public String infoId ; + public String acId ; + public String name ; + public String subject ; + public int isOrder ; + public int type ; + public String workDesc ; + public long workEnd ; + + } + public static class Tasks { + public String id ; + public String quotaname ; + public List path ; + public List task ; + } + public static class ArtPeriod + { + public String id ; + public String name ; + } + public static class ArtSubject { + public String id ; + public String name ; + } + public static class LostStudent { + public String code ; + public String subject ; + public double stu ; + } + private static class Zymusicstd + { + public String code ; + public String label ; + public double percent ; + } +} + diff --git a/src/main/java/cn/teammodel/model/vo/admin/ArtElementsVo.java b/src/main/java/cn/teammodel/model/vo/admin/ArtElementsVo.java new file mode 100644 index 0000000..d7cf3e8 --- /dev/null +++ b/src/main/java/cn/teammodel/model/vo/admin/ArtElementsVo.java @@ -0,0 +1,34 @@ +package cn.teammodel.model.vo.admin; + +import cn.teammodel.model.entity.common.Art; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ArtElementsVo { + public String id; + public String name; + public List classes; + public long startTime; + public long endTime; + public List subjects; + public List classesInfos = new ArrayList<>(); + public int count; + public String progress; + + public void addClassesInfos(ClassInfos classInfos) { + this.classesInfos.add(classInfos); + } + + @Data + public static class ClassInfos { + public String id; + public String name; + } +} diff --git a/src/main/java/cn/teammodel/repository/ArtRepository.java b/src/main/java/cn/teammodel/repository/ArtRepository.java new file mode 100644 index 0000000..2a7f4d4 --- /dev/null +++ b/src/main/java/cn/teammodel/repository/ArtRepository.java @@ -0,0 +1,25 @@ +package cn.teammodel.repository; + +import cn.teammodel.model.entity.common.Art; +import cn.teammodel.model.vo.admin.ArtElementsVo; +import com.azure.spring.data.cosmos.repository.CosmosRepository; +import com.azure.spring.data.cosmos.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @author winter + * @create 2023-11-28 17:39 + */ +@Repository +public interface ArtRepository extends CosmosRepository { + /** + * 动态投影, 查询还是要将所有的值查出来,类的动态查询不能嵌套 + */ + @Query("select s.id,s.name,s.classes,s.startTime,s.endTime,s.subjects,s.progress from Art as s where s.period.id = @periodId and s.code = @code") + List findPeriodById(@Param("periodId")String periodId, @Param("code")String code); + + +}