|
|
@ -21,6 +21,7 @@ import cn.teammodel.repository.DutyRecordRepository;
|
|
|
|
import cn.teammodel.repository.SchoolRepository;
|
|
|
|
import cn.teammodel.repository.SchoolRepository;
|
|
|
|
import cn.teammodel.repository.TeacherRepository;
|
|
|
|
import cn.teammodel.repository.TeacherRepository;
|
|
|
|
import cn.teammodel.security.utils.SecurityUtil;
|
|
|
|
import cn.teammodel.security.utils.SecurityUtil;
|
|
|
|
|
|
|
|
import cn.teammodel.utils.GroupUtil;
|
|
|
|
import cn.teammodel.utils.JsonUtil;
|
|
|
|
import cn.teammodel.utils.JsonUtil;
|
|
|
|
import cn.teammodel.utils.SchoolDateUtil;
|
|
|
|
import cn.teammodel.utils.SchoolDateUtil;
|
|
|
|
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
|
|
|
|
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
|
|
|
@ -228,50 +229,14 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
|
|
|
|
public Map<String, Object> getLessonRecord(LessonRecordDto lessonRecordDto, HttpServletRequest request) {
|
|
|
|
public Map<String, Object> getLessonRecord(LessonRecordDto lessonRecordDto, HttpServletRequest request) {
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mapper = new HashMap<>();
|
|
|
|
Map<String, Object> mapper = new HashMap<>();
|
|
|
|
String apiUrl = env.getProperty("ies.server-url");
|
|
|
|
String url = env.getProperty("ies.server-url");
|
|
|
|
if(lessonRecordDto.isClassMeeting()) {
|
|
|
|
if(lessonRecordDto.isClassMeeting()) {
|
|
|
|
List<School.Subject> subjects = schoolRepository.findSubjectById(lessonRecordDto.getSchool(), lessonRecordDto.getPeriodId());
|
|
|
|
List<School.Subject> subjects = schoolRepository.findSubjectById(lessonRecordDto.getSchool(), lessonRecordDto.getPeriodId());
|
|
|
|
List<String> subjectIds = subjects.stream().filter(subject -> "班会".equals(subject.getName()))
|
|
|
|
List<String> subjectIds = subjects.stream().filter(subject -> "班会".equals(subject.getName()))
|
|
|
|
.map(School.Subject::getId).collect(Collectors.toList());
|
|
|
|
.map(School.Subject::getId).collect(Collectors.toList());
|
|
|
|
lessonRecordDto.setSubjectId(subjectIds);
|
|
|
|
lessonRecordDto.setSubjectId(subjectIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mapper = GroupUtil.getGroupId(lessonRecordDto,new GroupUtil(env), request,url);
|
|
|
|
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(lessonRecordDto);
|
|
|
|
|
|
|
|
//String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId);
|
|
|
|
|
|
|
|
httpPost.setEntity(new StringEntity(JsonUtil.convertToJson(lessonRecordDto)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 发送请求
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
log.error("Failed : HTTP error code : {}", e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
log.error("Failed : HTTP error code : {}", e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return mapper;
|
|
|
|
return mapper;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|