From 8198da6fa52696462f7f5231cece429fbf9a886c Mon Sep 17 00:00:00 2001 From: "zhouj1203@hotmail.com" Date: Mon, 26 Aug 2024 09:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3=E8=89=BA?= =?UTF-8?q?=E6=9C=AF=E6=A8=A1=E5=9D=97pdf=E6=93=8D=E4=BD=9C=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=99=BA=E8=82=B2=E6=A8=A1=E5=9D=97API=20?= =?UTF-8?q?=E5=88=86=E7=BB=84=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 | 15 ++++++ .../admin/controller/ExamController.java | 33 ++++++++++++ .../controller/admin/service/ArtService.java | 5 ++ .../controller/admin/service/ExamService.java | 10 ++++ .../admin/service/impl/ArtServiceImpl.java | 53 ++++++++++++++++++- .../admin/service/impl/ExamServiceImpl.java | 45 ++++++++++++++++ .../dto/admin/art/DataFileCommentDto.java | 19 +++++++ .../model/dto/admin/art/DataFileDto.java | 15 ++++++ .../model/dto/admin/exam/OverViewDto.java | 16 ++++++ .../teammodel/model/vo/admin/DataFileVo.java | 11 ++++ .../java/cn/teammodel/utils/GroupUtil.java | 5 +- src/main/resources/application.yml | 5 +- 12 files changed, 227 insertions(+), 5 deletions(-) create mode 100644 src/main/java/cn/teammodel/controller/admin/controller/ExamController.java create mode 100644 src/main/java/cn/teammodel/controller/admin/service/ExamService.java create mode 100644 src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java create mode 100644 src/main/java/cn/teammodel/model/dto/admin/art/DataFileCommentDto.java create mode 100644 src/main/java/cn/teammodel/model/dto/admin/art/DataFileDto.java create mode 100644 src/main/java/cn/teammodel/model/dto/admin/exam/OverViewDto.java create mode 100644 src/main/java/cn/teammodel/model/vo/admin/DataFileVo.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 index 3c55ac2..0703623 100644 --- a/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java +++ b/src/main/java/cn/teammodel/controller/admin/controller/ArtController.java @@ -3,9 +3,12 @@ package cn.teammodel.controller.admin.controller; import cn.teammodel.common.R; import cn.teammodel.controller.admin.service.ArtService; import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.dto.admin.art.DataFileCommentDto; +import cn.teammodel.model.dto.admin.art.DataFileDto; import cn.teammodel.model.dto.admin.common.GroupDto; import cn.teammodel.model.dto.admin.common.RGroupList; import cn.teammodel.model.vo.admin.ArtElementsVo; +import cn.teammodel.model.vo.admin.DataFileVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; @@ -35,5 +38,17 @@ public class ArtController { List res = ArtService.getGroupList(groupDto,request); return R.success(res); } + @PostMapping("getPdfData") + @ApiOperation("请求学生的pdf数据文件") + public R> getPdfData(@Valid @RequestBody DataFileDto dataFileDto, HttpServletRequest request) { + List res = ArtService.getPdfData(dataFileDto,request); + return R.success(res); + } + @PostMapping("updateComment") + @ApiOperation("更新评论") + public R> updateComment(@Valid @RequestBody DataFileCommentDto dataFileCommentDto, HttpServletRequest request) { + List res = ArtService.updateComment(dataFileCommentDto,request); + return R.success(res); + } } diff --git a/src/main/java/cn/teammodel/controller/admin/controller/ExamController.java b/src/main/java/cn/teammodel/controller/admin/controller/ExamController.java new file mode 100644 index 0000000..7d0b7e8 --- /dev/null +++ b/src/main/java/cn/teammodel/controller/admin/controller/ExamController.java @@ -0,0 +1,33 @@ +package cn.teammodel.controller.admin.controller; + +import cn.teammodel.common.R; +import cn.teammodel.controller.admin.service.ExamService; +import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.dto.admin.exam.OverViewDto; +import cn.teammodel.model.vo.admin.ArtElementsVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("admin/exam") +@Api(tags = "管理员端-智育分析") +public class ExamController { + @Resource + private ExamService examService; + @PostMapping("getOverView") + @ApiOperation("获取当前学校艺术评测列表") + public R> getOverView(@Valid @RequestBody OverViewDto overViewDto, HttpServletRequest request) { + Map res = examService.getAnalysis(overViewDto,request); + 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 index cd962bc..8385a08 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/ArtService.java +++ b/src/main/java/cn/teammodel/controller/admin/service/ArtService.java @@ -1,9 +1,12 @@ package cn.teammodel.controller.admin.service; import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.dto.admin.art.DataFileCommentDto; +import cn.teammodel.model.dto.admin.art.DataFileDto; import cn.teammodel.model.dto.admin.common.GroupDto; import cn.teammodel.model.dto.admin.common.RGroupList; import cn.teammodel.model.vo.admin.ArtElementsVo; +import cn.teammodel.model.vo.admin.DataFileVo; import javax.servlet.http.HttpServletRequest; import java.util.List; @@ -11,4 +14,6 @@ import java.util.List; public interface ArtService { List getArtList(ArtFindDto artFindDto, HttpServletRequest request); List getGroupList(GroupDto groupDto, HttpServletRequest request); + List getPdfData(DataFileDto dataFileDto,HttpServletRequest request); + List updateComment(DataFileCommentDto dataFileCommentDto, HttpServletRequest request); } diff --git a/src/main/java/cn/teammodel/controller/admin/service/ExamService.java b/src/main/java/cn/teammodel/controller/admin/service/ExamService.java new file mode 100644 index 0000000..aed11df --- /dev/null +++ b/src/main/java/cn/teammodel/controller/admin/service/ExamService.java @@ -0,0 +1,10 @@ +package cn.teammodel.controller.admin.service; + +import cn.teammodel.model.dto.admin.exam.OverViewDto; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public interface ExamService { + Map getAnalysis(OverViewDto overViewDto, HttpServletRequest request); +} 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 index 25e0d90..a0af0e2 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java @@ -1,11 +1,16 @@ package cn.teammodel.controller.admin.service.impl; +import cn.teammodel.common.ErrorCode; +import cn.teammodel.config.exception.ServiceException; import cn.teammodel.controller.admin.service.ArtService; import cn.teammodel.model.dto.admin.art.ArtFindDto; +import cn.teammodel.model.dto.admin.art.DataFileCommentDto; +import cn.teammodel.model.dto.admin.art.DataFileDto; 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.vo.admin.ArtElementsVo; +import cn.teammodel.model.vo.admin.DataFileVo; import cn.teammodel.repository.ArtRepository; import cn.teammodel.repository.ClassRepository; import cn.teammodel.repository.StudentRepository; @@ -75,7 +80,7 @@ public class ArtServiceImpl implements ArtService { } } catch (Exception e) { - throw new RuntimeException(e); + throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误"); } return artElementsVos; } @@ -97,9 +102,53 @@ public class ArtServiceImpl implements ArtService { } }catch (Exception e) { - throw new RuntimeException(e); + throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误"); } return rGroupList; } + + @Override + public List getPdfData(DataFileDto dataFileDto,HttpServletRequest request) { + List dataFile = new ArrayList<>(); + String url = env.getProperty("ies.server-url-pdf-data"); + try { + Map groupId = GroupUtil.getGroupId(dataFileDto,new GroupUtil(env), request,url); + //List rMembers = new ArrayList<>(); + for (Map.Entry entry : groupId.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (key.equals("dataFiles")) { + String jsonGroups = JSON.toJSONString(value); + dataFile = JSON.parseObject(jsonGroups, new TypeReference>() {}); + } + } + }catch (Exception e) { + throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误"); + + } + return dataFile; + } + + @Override + public List updateComment(DataFileCommentDto dataFileCommentDto, HttpServletRequest request) { + List dataFile = new ArrayList<>(); + String url = env.getProperty("ies.server-url-update-custom-comment"); + try { + Map groupId = GroupUtil.getGroupId(dataFileCommentDto,new GroupUtil(env), request,url); + //List rMembers = new ArrayList<>(); + for (Map.Entry entry : groupId.entrySet()) { + String key = entry.getKey(); + Object value = entry.getValue(); + if (key.equals("dataFile")) { + String jsonGroups = JSON.toJSONString(value); + dataFile = JSON.parseObject(jsonGroups, new TypeReference>() {}); + } + } + }catch (Exception e) { + throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误"); + + } + return dataFile; + } } diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java new file mode 100644 index 0000000..4971a51 --- /dev/null +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/ExamServiceImpl.java @@ -0,0 +1,45 @@ +package cn.teammodel.controller.admin.service.impl; + +import cn.teammodel.common.ErrorCode; +import cn.teammodel.config.exception.ServiceException; +import cn.teammodel.controller.admin.service.ExamService; +import cn.teammodel.model.dto.admin.common.RGroupList; +import cn.teammodel.model.dto.admin.exam.OverViewDto; +import cn.teammodel.utils.GroupUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +@Service +public class ExamServiceImpl implements ExamService { + + @Autowired + private Environment env; + @Override + public Map getAnalysis(OverViewDto overViewDto, HttpServletRequest request) { + + Map overView; + String url = env.getProperty("ies.server-url-overview"); + try { + overView = GroupUtil.getGroupId(overViewDto,new GroupUtil(env), request,url); + //List rMembers = new ArrayList<>(); + /*for (Map.Entry 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>() {}); + } + }*/ + }catch (Exception e) { + throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据转换错误"); + + } + return overView; + } +} diff --git a/src/main/java/cn/teammodel/model/dto/admin/art/DataFileCommentDto.java b/src/main/java/cn/teammodel/model/dto/admin/art/DataFileCommentDto.java new file mode 100644 index 0000000..5421c11 --- /dev/null +++ b/src/main/java/cn/teammodel/model/dto/admin/art/DataFileCommentDto.java @@ -0,0 +1,19 @@ +package cn.teammodel.model.dto.admin.art; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class DataFileCommentDto { + private String artId; + private String schoolId; + private String schoolCode; + private String headLang; + private String studentId; + @ApiModelProperty(value = "自定义评语,不传或者传空字符串代表清空之前的") + private String comment; + @ApiModelProperty(value = "自定义评语音乐,不传或者传空字符串代表清空之前的") + private String comment_music; + @ApiModelProperty(value = "自定义评语美术,不传或者传空字符串代表清空之前的") + private String comment_painting; +} diff --git a/src/main/java/cn/teammodel/model/dto/admin/art/DataFileDto.java b/src/main/java/cn/teammodel/model/dto/admin/art/DataFileDto.java new file mode 100644 index 0000000..c3158ad --- /dev/null +++ b/src/main/java/cn/teammodel/model/dto/admin/art/DataFileDto.java @@ -0,0 +1,15 @@ +package cn.teammodel.model.dto.admin.art; + +import lombok.Data; + +import java.util.List; + +@Data +public class DataFileDto { + private String artId; + private String schoolId; + private String schoolCode; + private String opt; + private String headLang; + List studentIds; +} diff --git a/src/main/java/cn/teammodel/model/dto/admin/exam/OverViewDto.java b/src/main/java/cn/teammodel/model/dto/admin/exam/OverViewDto.java new file mode 100644 index 0000000..57c3661 --- /dev/null +++ b/src/main/java/cn/teammodel/model/dto/admin/exam/OverViewDto.java @@ -0,0 +1,16 @@ +package cn.teammodel.model.dto.admin.exam; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class OverViewDto { + @ApiModelProperty("指定学年") + private int studyYear; + private String semesterId; + private String school; + private String studentId; + private String periodId; + @ApiModelProperty("学生入学年") + private int studentYear; +} diff --git a/src/main/java/cn/teammodel/model/vo/admin/DataFileVo.java b/src/main/java/cn/teammodel/model/vo/admin/DataFileVo.java new file mode 100644 index 0000000..ff1686e --- /dev/null +++ b/src/main/java/cn/teammodel/model/vo/admin/DataFileVo.java @@ -0,0 +1,11 @@ +package cn.teammodel.model.vo.admin; + +import lombok.Data; +import java.util.List; + +@Data +public class DataFileVo { + public String blob; + public String blobFullUrl; + +} diff --git a/src/main/java/cn/teammodel/utils/GroupUtil.java b/src/main/java/cn/teammodel/utils/GroupUtil.java index 58975d4..b044f5a 100644 --- a/src/main/java/cn/teammodel/utils/GroupUtil.java +++ b/src/main/java/cn/teammodel/utils/GroupUtil.java @@ -6,6 +6,7 @@ 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.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; @@ -51,9 +52,9 @@ public class GroupUtil { httpPost.setHeader("Content-Type", "application/json; charset=utf-8"); // 设置请求体 - //JsonUtil.convertToJson(dto); + String jsonContent = JsonUtil.convertToJson(obj); //String requestBody = String.format("{\"school\":\"%s\"}","{\"name\":\"%s\"}","{\"periodId\":\"%s\"}", code,name,periodId); - httpPost.setEntity(new StringEntity(JsonUtil.convertToJson(obj))); + httpPost.setEntity(new StringEntity(jsonContent, ContentType.create("application/json", "UTF-8"))); // 发送请求 try (CloseableHttpResponse response = httpClient.execute(httpPost)) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 635bb41..2dc1d12 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -69,4 +69,7 @@ ding: #IES 课堂记录 ies: server-url: /common/lesson-record/get-lesson-record - server-url-group: /grouplist/get-members-listids \ No newline at end of file + server-url-group: /grouplist/get-members-listids + server-url-pdf-data: /school/art/get-pdf-data + server-url-update-custom-comment: /school/art/update-custom-comment + server-url-overview: /overall-education/overview \ No newline at end of file