更新艺术评测相关内容 名单提取

11111
zhouj1203@hotmail.com 4 months ago
parent d880be517b
commit 6587bcca67

@ -33,8 +33,8 @@ public class ArtController {
@PostMapping("getArtList") @PostMapping("getArtList")
@ApiOperation("获取当前学校艺术评测列表") @ApiOperation("获取当前学校艺术评测列表")
public R<List<ArtElementsVo>> findRecords(@Valid @RequestBody ArtFindDto artFindDto) { public R<List<ArtElementsVo>> findRecords(@Valid @RequestBody ArtFindDto artFindDto,HttpServletRequest request) {
List<ArtElementsVo> res = ArtService.getArtList(artFindDto); List<ArtElementsVo> res = ArtService.getArtList(artFindDto,request);
return R.success(res); return R.success(res);
} }

@ -3,9 +3,10 @@ package cn.teammodel.controller.admin.service;
import cn.teammodel.model.dto.admin.art.ArtFindDto; import cn.teammodel.model.dto.admin.art.ArtFindDto;
import cn.teammodel.model.vo.admin.ArtElementsVo; import cn.teammodel.model.vo.admin.ArtElementsVo;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public interface ArtService { public interface ArtService {
List<ArtElementsVo> getArtList(ArtFindDto artFindDto); List<ArtElementsVo> getArtList(ArtFindDto artFindDto, HttpServletRequest request);
} }

@ -3,20 +3,25 @@ package cn.teammodel.controller.admin.service.impl;
import cn.teammodel.common.PK; import cn.teammodel.common.PK;
import cn.teammodel.controller.admin.service.ArtService; import cn.teammodel.controller.admin.service.ArtService;
import cn.teammodel.model.dto.admin.art.ArtFindDto; import cn.teammodel.model.dto.admin.art.ArtFindDto;
import cn.teammodel.model.dto.admin.common.GroupDto;
import cn.teammodel.model.dto.admin.common.RGroupList;
import cn.teammodel.model.dto.admin.common.RMember;
import cn.teammodel.model.entity.school.ClassInfo; import cn.teammodel.model.entity.school.ClassInfo;
import cn.teammodel.model.vo.admin.ArtElementsVo; import cn.teammodel.model.vo.admin.ArtElementsVo;
import cn.teammodel.repository.ArtRepository; import cn.teammodel.repository.ArtRepository;
import cn.teammodel.repository.ClassRepository; import cn.teammodel.repository.ClassRepository;
import cn.teammodel.repository.StudentRepository; import cn.teammodel.repository.StudentRepository;
import cn.teammodel.utils.GroupUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
@Service @Service
public class ArtServiceImpl implements ArtService { public class ArtServiceImpl implements ArtService {
@Resource @Resource
@ -25,31 +30,48 @@ public class ArtServiceImpl implements ArtService {
private ClassRepository classRepository; private ClassRepository classRepository;
@Resource @Resource
private StudentRepository studentRepository; private StudentRepository studentRepository;
@Autowired
private Environment env;
@Override @Override
public List<ArtElementsVo> getArtList(ArtFindDto artFindDto) { public List<ArtElementsVo> getArtList(ArtFindDto artFindDto, HttpServletRequest request) {
List<ArtElementsVo> artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode()); List<ArtElementsVo> artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode());
List<String> classIds = artElementsVos.stream() List<String> classIds = artElementsVos.stream()
.map(ArtElementsVo::getClasses) // 正确的方法引用 .map(ArtElementsVo::getClasses) // 正确的方法引用
.flatMap(List::stream) // 将内部列表扁平化 .flatMap(List::stream) // 将内部列表扁平化
.collect(Collectors.toList()); .collect(Collectors.toList());
GroupDto groupDto = new GroupDto();
List<ClassInfo> classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds); groupDto.setIds(classIds);
groupDto.setSchoolId(artFindDto.getCode());
//List<ClassInfo> classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds);
Map<String, Object> groupId = GroupUtil.getGroupId(groupDto,new GroupUtil(env), request);
List<RGroupList> rGroupList = new ArrayList<>();
List<RMember> rMembers = new ArrayList<>();
for (Map.Entry<String, Object> entry : groupId.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.equals("groups")) {
String jsonGroups = JSON.toJSONString(value);
rGroupList = JSON.parseObject(jsonGroups, new TypeReference<List<RGroupList>>() {});
}
if (key.equals("members")) {
String jsonGroups = JSON.toJSONString(value);
rMembers = JSON.parseObject(jsonGroups, new TypeReference<List<RMember>>() {});
}
}
try { try {
for (ArtElementsVo artElementsVo : artElementsVos) { for (ArtElementsVo artElementsVo : artElementsVos) {
List<String> classes1 = artElementsVo.getClasses(); List<String> classes1 = artElementsVo.getClasses();
int stuInClassCount = 0; //int stuInClassCount = 0;
for(String classId : classes1) { for(String classId : classes1) {
stuInClassCount += studentRepository.countByClassIdAndCode(classId, String.format(PK.STUDENT, artFindDto.getCode())); //stuInClassCount += studentRepository.countByClassIdAndCode(classId, String.format(PK.STUDENT, artFindDto.getCode()));
ArtElementsVo.ClassInfos classInfos = new ArtElementsVo.ClassInfos(); ArtElementsVo.ClassInfos classInfos = new ArtElementsVo.ClassInfos();
Optional<String> className = classes.stream() rGroupList.stream().filter(rGroupList1 -> rGroupList1.getId().equals(classId)).findFirst().ifPresent(rGroupList1 -> {
.filter(classInfo -> classInfo.getId().equals(classId)) classInfos.setId(rGroupList1.getId());
.map(ClassInfo::getName) classInfos.setName(rGroupList1.getName());
.findFirst(); });
classInfos.setId(classId);
classInfos.setName(className.orElse("No Class Name"));
artElementsVo.addClassesInfos(classInfos); artElementsVo.addClassesInfos(classInfos);
} }
artElementsVo.setCount(stuInClassCount); artElementsVo.setCount(rMembers.size());
} }
} catch (Exception e) { } catch (Exception e) {

@ -0,0 +1,11 @@
package cn.teammodel.model.dto.admin.common;
import lombok.Data;
import java.util.List;
@Data
public class GroupDto {
public List<String> ids;
public String schoolId;
}

@ -0,0 +1,73 @@
package cn.teammodel.model.dto.admin.common;
import lombok.Data;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@Data
public class RGroupList {
public String id ;
public String code ;
public String pk ;
public String name ;
//标记该名单唯一code
public String no ;
public String periodId ;
//课程id,需要标记则标记
//public String courseId ;
public String scope ;
public String school ;
public String creatorId ;
/// <summary>
///研修培训名单yxtrain 教学班teach 行政班学生搜寻classId动态返回class ,教研组research学科组学科搜寻动态返回subject好友friend管理manage群组group等,"activity",
///TeacherAll 全体教师StudentAll全体学生 TchStuAll全体师生 动态返回
/// </summary>
public String type ;
public int year ;
/// <summary>
/// 名单过期时间。
/// </summary>
public long expire ;
/// <summary>
/// 醍摩豆id成员数量
/// </summary>
public int tcount ;
/// <summary>
/// 校内账号成员数量
/// </summary>
public int scount ;
public List<RMember> members = new ArrayList<>();
public String leader ;
public int froms ;
/// <summary>
/// 个人名单是否开放 加入。0 不允许1 允许。
/// </summary>
public int joinLock ;
/// <summary>
///补充毕业0在校1毕业
/// </summary>
public int graduate ;
/// <summary>
/// 是否开启审核0未开启1开启。
/// </summary>
public int review ;
/// <summary>
/// 加入人数200人学生加入已满200 自动关闭加入。可手动解除限制,开启审核时,关闭人数上限设置机制
/// </summary>
public int limitCount ;
/// <summary>
/// 自选座号 0 不允许1 运行
/// </summary>
public int optNo ;
/// <summary>
/// 二维码过期时间
/// </summary>
public long qrcodeExpire ;
/// <summary>
/// 二维码 天数
/// </summary>
public int qrcodeDays ;
public HashSet<Integer> grades = new HashSet<Integer>();
}

@ -0,0 +1,73 @@
package cn.teammodel.model.dto.admin.common;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class RMember {
/// <summary>
/// 账号id
/// </summary>
public String id ;
//学生所在的学校
public String code ;
//兼容HiTeach 需要的字段
public String schoolId ;
//学生所在的学校
public String schoolName ;
/// <summary>
/// 名称
/// </summary>
public String name ;
/// <summary>
///类型 1 tmdid,2 student
/// </summary>
public int type ;
/// <summary>
/// 头像
/// </summary>
public String picture ;
/// <summary>
/// 性别 M( male,男) F (female 女) N(secret 保密)
/// </summary>
public String gender ;
/// <summary>
///座号
/// </summary>
public String no ;
/// <summary>
/// IRS WebIRS编号。
/// </summary>
public String irs ;
public String tag ;
/// <summary>
/// 行政班
/// </summary>
public String classId ;
/// <summary>
/// 名单分组id
/// </summary>
public String groupId ;
/// <summary>
/// 名单分组名称
/// </summary>
public String groupName ;
public String nickname ;
//补充毕业
//0在校1毕业
public int graduate ;
//所在名单集合
public List<String> groupListIds = new ArrayList<String>();
public int year ;
public String periodId ;
/// <summary>
/// 0 自动的座号和irs,1 手动的irs
/// </summary>
public int manual ;
}

@ -0,0 +1,72 @@
package cn.teammodel.utils;
import cn.teammodel.model.dto.admin.common.GroupDto;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.env.Environment;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class GroupUtil {
private final Environment env;
public GroupUtil(Environment env) {
this.env = env;
}
public static Map<String, Object> getGroupId(GroupDto dto, GroupUtil groupUtil, HttpServletRequest request) {
Map<String, Object> mapper = new HashMap<>();
String apiUrl = groupUtil.env.getProperty("ies.server-url-group");
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// 创建HttpPost对象
HttpPost httpPost = new HttpPost(apiUrl);
//添加请求头
httpPost.setHeader("Authorization", request.getHeader("Authorization"));
httpPost.setHeader("X-Auth-Authtoken", request.getHeader("X-Auth-Authtoken"));
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
// 设置请求体
//JsonUtil.convertToJson(dto);
//String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId);
httpPost.setEntity(new StringEntity(JsonUtil.convertToJson(dto)));
// 发送请求
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
// 获取响应实体
HttpEntity entity = response.getEntity();
if (entity != null) {
// 解析响应内容
String jsonString = EntityUtils.toString(entity);
ObjectMapper objectMapper = new ObjectMapper();
mapper = objectMapper.readValue(jsonString, TypeFactory.defaultInstance().constructMapType(Map.class, String.class, Object.class));
}
// 检查响应状态码
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200) throw new RuntimeException("Failed : HTTP error code : " + statusCode);
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
return mapper;
}
}

@ -61,4 +61,5 @@ ding:
server-url: https://oapi.dingtalk.com/robot/send?access_token=32d9b24f69c2c4fd7c2dab43268b6258a7214d2620e0805d7b6d1429003b64b6 server-url: https://oapi.dingtalk.com/robot/send?access_token=32d9b24f69c2c4fd7c2dab43268b6258a7214d2620e0805d7b6d1429003b64b6
#IES 课堂记录 #IES 课堂记录
ies: ies:
server-url: https://www.teammodel.cn/common/lesson-record/get-lesson-record server-url: https://www.teammodel.cn/common/lesson-record/get-lesson-record
server-url-group: https://www.teammodel.cn/grouplist/get-members-listids
Loading…
Cancel
Save