|
|
|
@ -3,8 +3,10 @@ package cn.teammodel.controller.admin.service.impl;
|
|
|
|
|
import cn.teammodel.common.ErrorCode;
|
|
|
|
|
import cn.teammodel.common.PK;
|
|
|
|
|
import cn.teammodel.config.exception.ServiceException;
|
|
|
|
|
import cn.teammodel.config.ies.IESConfig;
|
|
|
|
|
import cn.teammodel.controller.admin.service.AdminIndexDutyService;
|
|
|
|
|
import cn.teammodel.model.dto.admin.appraise.TimeRangeDto;
|
|
|
|
|
import cn.teammodel.model.dto.weekDuty.LessonRecordDto;
|
|
|
|
|
import cn.teammodel.model.entity.User;
|
|
|
|
|
import cn.teammodel.model.entity.school.ClassInfo;
|
|
|
|
|
import cn.teammodel.model.entity.school.School;
|
|
|
|
@ -21,12 +23,31 @@ import cn.teammodel.repository.TeacherRepository;
|
|
|
|
|
import cn.teammodel.security.utils.SecurityUtil;
|
|
|
|
|
import cn.teammodel.utils.SchoolDateUtil;
|
|
|
|
|
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.JsonElement;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import lombok.val;
|
|
|
|
|
import lombok.var;
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.http.HttpEntity;
|
|
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
|
|
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.core.env.Environment;
|
|
|
|
|
import org.springframework.data.domain.Slice;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -39,6 +60,7 @@ import static cn.teammodel.utils.SchoolDateUtil.calculateWeekNum;
|
|
|
|
|
* @create 2024-02-28 15:07
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@ -52,6 +74,13 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
|
|
|
|
|
@Resource
|
|
|
|
|
private DutyRecordRepository dutyRecordRepository;
|
|
|
|
|
|
|
|
|
|
private final Environment env;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
public AdminIndexDutyServiceImpl(Environment env) {
|
|
|
|
|
this.env = env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public DutyIndexData getIndexData(String periodId) {
|
|
|
|
|
User loginUser = SecurityUtil.getLoginUser();
|
|
|
|
@ -193,4 +222,48 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getLessonRecord(Map<String, Object> map, HttpServletRequest request) {
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mapper = new HashMap<>();
|
|
|
|
|
String apiUrl = env.getProperty("ies.server-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");
|
|
|
|
|
|
|
|
|
|
// 设置请求体
|
|
|
|
|
//String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId);
|
|
|
|
|
httpPost.setEntity(new StringEntity(new Gson().toJson(map)));
|
|
|
|
|
|
|
|
|
|
// 发送请求
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|