parent
3451287df9
commit
8e9d78dcc4
@ -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<List<ArtElementsVo>> findRecords(@Valid @RequestBody ArtFindDto artFindDto) {
|
||||
List<ArtElementsVo> res = ArtService.getArtList(artFindDto);
|
||||
return R.success(res);
|
||||
}
|
||||
|
||||
}
|
@ -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<ArtElementsVo> getArtList(ArtFindDto artFindDto);
|
||||
}
|
@ -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<ArtElementsVo> getArtList(ArtFindDto artFindDto) {
|
||||
List<ArtElementsVo> artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode());
|
||||
List<String> classIds = artElementsVos.stream()
|
||||
.map(ArtElementsVo::getClasses) // 正确的方法引用
|
||||
.flatMap(List::stream) // 将内部列表扁平化
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<ClassInfo> classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds);
|
||||
try {
|
||||
for (ArtElementsVo artElementsVo : artElementsVos) {
|
||||
List<String> 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<String> 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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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<Tasks> settings;
|
||||
public String creatorId;
|
||||
public String createTime;
|
||||
public String updateTime;
|
||||
public int type;
|
||||
public List<String> classes;
|
||||
public List<String> stuLists;
|
||||
public List<String> tchLists;
|
||||
public List<String> 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<ArtSubject> subjects;
|
||||
public ArtPeriod period;
|
||||
public String periodType;
|
||||
public List<LostStudent> lost;
|
||||
public int pass;
|
||||
public List<Integer> miss;
|
||||
public List<Zymusicstd> 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<String> path ;
|
||||
public List<Acs> 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 ;
|
||||
}
|
||||
}
|
||||
|
@ -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<String> classes;
|
||||
public long startTime;
|
||||
public long endTime;
|
||||
public List<Art.ArtSubject> subjects;
|
||||
public List<ClassInfos> 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;
|
||||
}
|
||||
}
|
@ -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<Art, String> {
|
||||
/**
|
||||
* 动态投影, 查询还是要将所有的值查出来,类的动态查询不能嵌套
|
||||
*/
|
||||
@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<ArtElementsVo> findPeriodById(@Param("periodId")String periodId, @Param("code")String code);
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue