|
@@ -0,0 +1,309 @@
|
|
|
+package com.ssj.sys.controller;
|
|
|
+
|
|
|
+
|
|
|
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ssj.api.domain.vo.vacation.*;
|
|
|
+import com.ssj.api.filter.VacationExcelImportHelper;
|
|
|
+import com.ssj.api.filter.VacationImportListener;
|
|
|
+import com.ssj.api.security.annotation.IgnoreSecurity;
|
|
|
+import com.ssj.framework.basic.config.bean.VersionConfig;
|
|
|
+import com.ssj.framework.core.common.controller.BaseController;
|
|
|
+import com.ssj.framework.core.util.*;
|
|
|
+import com.ssj.mapper.vacation.PrevMaterialMapper;
|
|
|
+import com.ssj.service.vacation.ISummerVacationService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author sh
|
|
|
+ * @className SummerVacationController
|
|
|
+ * @description 暑假大作战
|
|
|
+ * @date 2022/6/14
|
|
|
+ */
|
|
|
+@Api(tags = "暑假大作战相关接口")
|
|
|
+@Controller
|
|
|
+@RequestMapping("/sys/summerVacation")
|
|
|
+@Slf4j
|
|
|
+public class SummerVacationController extends BaseController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ISummerVacationService summerVacationService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private VacationExcelImportHelper excelImportHelper;
|
|
|
+
|
|
|
+ @RequestMapping("/index")
|
|
|
+ public String vacationIndex(Model model){
|
|
|
+ return "sys/vacation/review";
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/get/vacationVersionName", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "获取教材版本", notes = "获取教材版本")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseJrEntity vacationVersionName(@RequestBody VersionVo param) {
|
|
|
+ ResponseJrEntity responseEntity = new ResponseJrEntity();
|
|
|
+ try {
|
|
|
+ Map<String, List<VersionConfig>> data = SystemResourceLocator.getVersionList(param.getSubject());
|
|
|
+ List<Map<String,Object>> list = new ArrayList<>();
|
|
|
+ for(String key:data.keySet()) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("courseName",key);
|
|
|
+ map.put("versionList",data.get(key));
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ responseEntity.success(list, "获取教材版本成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("获取教材版本接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/get/vacationPrePage", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "获取预习列表", notes = "获取预习列表")
|
|
|
+ @ResponseBody
|
|
|
+ public TableDataInfo vacationPrePage(@RequestBody VersionVo param) {
|
|
|
+ Page<SumPrevMaterialVO> prevPage = summerVacationService.getPrevPage(param);
|
|
|
+
|
|
|
+ return TableDataInfo.success(prevPage.getTotal(),
|
|
|
+ prevPage.getRecords().stream()
|
|
|
+ .map(item -> {
|
|
|
+ List<SumPrevMaterialUnitVO> list = summerVacationService.getUnitList(item.getId());
|
|
|
+ Map<String,List<SumPrevMaterialUnitVO>> groupMap = list.stream().collect(Collectors.groupingBy(SumPrevMaterialUnitVO::getUnitId));
|
|
|
+ List<SumPrevMaterialUnitVO> lastList = new ArrayList<>();
|
|
|
+ for(String key:groupMap.keySet()){
|
|
|
+ List<SumPrevMaterialUnitVO> temp = groupMap.get(key);
|
|
|
+ temp.sort(Comparator.comparing(SumPrevMaterialUnitVO::getCreateTime));
|
|
|
+ SumPrevMaterialUnitVO temp2 = new SumPrevMaterialUnitVO();
|
|
|
+ List<Map<String,String>> mList = new ArrayList<>();
|
|
|
+ boolean add = true;
|
|
|
+ for(SumPrevMaterialUnitVO vo:temp){
|
|
|
+ if(add){
|
|
|
+ temp2.setId(vo.getId());
|
|
|
+ temp2.setGrade(vo.getGrade());
|
|
|
+ temp2.setUnitId(vo.getUnitId());
|
|
|
+ temp2.setUnitName(vo.getUnitName());
|
|
|
+ temp2.setUnitSort(vo.getUnitSort());
|
|
|
+ add = false;
|
|
|
+ }
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ if(StringUtils.isNotBlank(vo.getVideoName())){
|
|
|
+ map.put("videoName",vo.getVideoName());
|
|
|
+ map.put("videoLink",vo.getVideoLink());
|
|
|
+ mList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ temp2.setVideoList(mList);
|
|
|
+ lastList.add(temp2);
|
|
|
+ }
|
|
|
+ item.setUnitList(lastList);
|
|
|
+ return item;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ List<SumPrevMaterialUnitVO> list = new ArrayList<>();
|
|
|
+ SumPrevMaterialUnitVO vox = new SumPrevMaterialUnitVO();
|
|
|
+ vox.setUnitId("1");
|
|
|
+ vox.setVideoName("name1");
|
|
|
+ vox.setVideoLink("link1");
|
|
|
+ vox.setCreateTime(new Date());
|
|
|
+ list.add(vox);
|
|
|
+ SumPrevMaterialUnitVO vo2 = new SumPrevMaterialUnitVO();
|
|
|
+ vo2.setUnitId("1");
|
|
|
+ vo2.setVideoName("name2");
|
|
|
+ vo2.setVideoLink("link2");
|
|
|
+ vo2.setCreateTime(new Date());
|
|
|
+ list.add(vo2);
|
|
|
+ SumPrevMaterialUnitVO vo3 = new SumPrevMaterialUnitVO();
|
|
|
+ vo3.setUnitId("2");
|
|
|
+ vo3.setVideoName("name3");
|
|
|
+ vo3.setVideoLink("link3");
|
|
|
+ vo3.setCreateTime(new Date());
|
|
|
+ list.add(vo3);
|
|
|
+ SumPrevMaterialUnitVO vo4 = new SumPrevMaterialUnitVO();
|
|
|
+ vo4.setUnitId("2");
|
|
|
+ vo4.setVideoName("name4");
|
|
|
+ vo4.setVideoLink("link4");
|
|
|
+ vo4.setCreateTime(new Date());
|
|
|
+ list.add(vo4);
|
|
|
+
|
|
|
+ Map<String,List<SumPrevMaterialUnitVO>> groupMap = list.stream().collect(Collectors.groupingBy(SumPrevMaterialUnitVO::getUnitId));
|
|
|
+ List<SumPrevMaterialUnitVO> lastList = new ArrayList<>();
|
|
|
+ for(String key:groupMap.keySet()){
|
|
|
+ List<SumPrevMaterialUnitVO> temp = groupMap.get(key);
|
|
|
+ temp.sort(Comparator.comparing(SumPrevMaterialUnitVO::getCreateTime));
|
|
|
+ SumPrevMaterialUnitVO temp2 = new SumPrevMaterialUnitVO();
|
|
|
+ List<Map<String,String>> mList = new ArrayList<>();
|
|
|
+ boolean add = true;
|
|
|
+ for(SumPrevMaterialUnitVO vo:temp){
|
|
|
+ if(add){
|
|
|
+ temp2.setId(vo.getId());
|
|
|
+ temp2.setGrade(vo.getGrade());
|
|
|
+ temp2.setUnitId(vo.getUnitId());
|
|
|
+ temp2.setUnitName(vo.getUnitName());
|
|
|
+ temp2.setUnitSort(vo.getUnitSort());
|
|
|
+ add = false;
|
|
|
+ }
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ if(StringUtils.isNotBlank(vo.getVideoName())){
|
|
|
+ map.put("videoName",vo.getVideoName());
|
|
|
+ map.put("videoLink",vo.getVideoLink());
|
|
|
+ mList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ temp2.setVideoList(mList);
|
|
|
+ lastList.add(temp2);
|
|
|
+ }
|
|
|
+ System.out.println(lastList.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/edit/preMaterialVersion", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "保存预习教材版本信息", notes = "保存预习教材版本信息")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseJrEntity editPreMaterialVersion(@RequestBody VersionVo param) {
|
|
|
+ ResponseJrEntity responseEntity = new ResponseJrEntity();
|
|
|
+ try {
|
|
|
+ summerVacationService.editPreMaterialVersion(param);
|
|
|
+ responseEntity.success("保存预习教材版本信息成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("保存预习教材版本信息接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/del/preMaterialVersion", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "删除预习教材版本信息", notes = "删除预习教材版本信息")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseJrEntity delPreMaterialVersion(@RequestBody VersionVo param) {
|
|
|
+ ResponseJrEntity responseEntity = new ResponseJrEntity();
|
|
|
+ try {
|
|
|
+ summerVacationService.delPreMaterialVersion(param);
|
|
|
+ responseEntity.success("删除预习教材版本信息成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("获取预习列表接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/edit/preUnitVersion", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "编辑或添加预习教材版本单元明细", notes = "编辑或添加预习教材版本单元明细")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseJrEntity editPreUnitVersion(@RequestBody VersionUnitVo param) {
|
|
|
+ ResponseJrEntity responseEntity = new ResponseJrEntity();
|
|
|
+ try {
|
|
|
+ summerVacationService.editPreUnitVersion(param);
|
|
|
+ responseEntity.success("保存预习教材版本信息成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("获取预习列表接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/del/preMaterialUnitVersion", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "删除预习教材版本单元明细", notes = "删除预习教材版本单元明细")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseJrEntity delPreMaterialUnitVersion(@RequestBody VersionVo param) {
|
|
|
+ ResponseJrEntity responseEntity = new ResponseJrEntity();
|
|
|
+ try {
|
|
|
+ summerVacationService.delPreMaterialUnitVersion(param);
|
|
|
+ responseEntity.success("删除预习教材版本单元明细成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("删除预习教材版本单元明细接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/get/vactionRevPage", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "获取复习列表", notes = "获取复习列表")
|
|
|
+ @ResponseBody
|
|
|
+ public TableDataInfo vacationRevPage(@RequestBody VersionVo param) {
|
|
|
+
|
|
|
+ Page<SumRevMaterialVO> prevPage = summerVacationService.vacationRevPage(param);
|
|
|
+ return TableDataInfo.success(prevPage.getTotal(),prevPage.getRecords());
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/edit/revMaterialVersion", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "编辑或添加复习教材版本", notes = "编辑或添加复习教材版本")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseJrEntity revMaterialVersion(@RequestBody VersionVo param) {
|
|
|
+ ResponseJrEntity responseEntity = new ResponseJrEntity();
|
|
|
+ try {
|
|
|
+ summerVacationService.revMaterialVersion(param);
|
|
|
+ responseEntity.success("保存复习教材版本成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("复习教材版本接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @IgnoreSecurity
|
|
|
+ @RequestMapping(value = "/del/revMaterialVersion", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "删除预习教材版本信息", notes = "删除预习教材版本信息")
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseJrEntity delRevMaterialVersion(@RequestBody VersionVo param) {
|
|
|
+ ResponseJrEntity responseEntity = new ResponseJrEntity();
|
|
|
+ try {
|
|
|
+ summerVacationService.delRevMaterialVersion(param);
|
|
|
+ responseEntity.success("删除预习教材版本信息成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("删除预习教材版本信息接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "upload/addMaterialAndUnit", method = RequestMethod.POST)
|
|
|
+ @ApiOperation("通过导入Excel添加学校")
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxResult<Void> addMaterialAndUnitExcelUpload(@RequestParam("file")MultipartFile file) {
|
|
|
+ try {
|
|
|
+ ImportParams params = new ImportParams();
|
|
|
+ params.setHeadRows(1);
|
|
|
+ List<SumPrevExcelImportVO> list = ExcelImportUtil.importExcel(
|
|
|
+ file.getInputStream(), SumPrevExcelImportVO.class, params);
|
|
|
+ excelImportHelper.dataImporting(list);
|
|
|
+// EasyExcel.read(file.getInputStream(), SumPrevExcelImportVO.class, vacationImportListener)
|
|
|
+// .sheet(0)
|
|
|
+// .headRowNumber(2)
|
|
|
+// .doRead();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("Add new school while uploading excel file throw an exception ======= {}", e.getMessage());
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|