- git mv src/main/java/com/bestsch/bschclassmanage -> src/main/java/com/yunhai/bschclassmanage - 255 个 Java 文件的 package/import 同步替换为 com.yunhai.bschclassmanage - pom.xml 项目 groupId 设为 com.yunhai(与外部依赖 com.bestsch:bsch-* 无关,未改动) - IDE 缓存 workspace.xml 路径同步更新(外部依赖坐标 com.bestsch:bsch-* 保持不动)
286 lines
12 KiB
Java
286 lines
12 KiB
Java
package com.yunhai.bschclassmanage.controller.api;
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
import com.yunhai.bschclassmanage.config.Config;
|
|
import com.yunhai.bschclassmanage.entity.SchClass;
|
|
import com.yunhai.bschclassmanage.model.excel.ImportRuleExcelColumn;
|
|
import com.yunhai.bschclassmanage.model.excel.SchClassExcelColumn;
|
|
import com.yunhai.bschclassmanage.model.excel.SchHeightClassExcelColumn;
|
|
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
|
|
import com.yunhai.bschclassmanage.model.vo.BaseSchClassVO;
|
|
import com.yunhai.bschclassmanage.model.vo.HigherSchClassVO;
|
|
import com.yunhai.bschclassmanage.model.vo.PageVO;
|
|
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
|
|
import com.yunhai.bschclassmanage.service.*;
|
|
import com.yunhai.bschclassmanage.utils.EasyPoiUtils;
|
|
import com.yunhai.bschclassmanage.utils.UserContext;
|
|
import com.yunhai.platform.utils.model.BoaUser;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@RequestMapping(Config.API_PATH+"/schclass/")
|
|
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
|
|
public class SchClassController {
|
|
|
|
@Autowired
|
|
private ISchClassService schClassService;
|
|
|
|
@Autowired
|
|
private IComSchTreeService comSchTreeService;
|
|
|
|
@Autowired
|
|
private IBaseSchsystemGradeService baseSchsystemGradeService;
|
|
|
|
@Autowired
|
|
private ISchTeacherService schTeacherService;
|
|
|
|
|
|
@Autowired
|
|
private ISchDicCampusService schDicCampusService;
|
|
|
|
@Autowired
|
|
private ISchDicDivisionService schDicDivisionService;
|
|
|
|
@Autowired
|
|
private ISchDicMajorsService schDicMajorsService;
|
|
|
|
|
|
@GetMapping("searcBaseSchClass")
|
|
public List<BaseSchClassVO> searcBaseSchClass(UserSysRole curRole,
|
|
@RequestParam(required = false) Integer schsystemId,
|
|
@RequestParam(required = false) Integer gradeId) {
|
|
return schClassService.searcBaseSchClass(curRole.getSchId(),schsystemId,gradeId,null);
|
|
}
|
|
|
|
@PostMapping("addBaseSchClass")
|
|
public void addBaseSchClass(BoaUser authUserWithDept, UserSysRole curRole, Integer gradeId, Integer number) {
|
|
schClassService.addBaseSchClass(UserContext.getCurrentUserInfo(),gradeId,number);
|
|
}
|
|
|
|
|
|
@PostMapping("editClassName")
|
|
public void editClassName(BoaUser authUserWithDept, UserSysRole curRole,Integer id,String cname) {
|
|
schClassService.editClassName(UserContext.getCurrentUserInfo(),id,cname);
|
|
}
|
|
|
|
@PostMapping("editClassFirstTeacher")
|
|
public void editClassfirstTeacher(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer firstTeacherId) {
|
|
schClassService.editClassFirstTeacher(UserContext.getCurrentUserInfo(),id,firstTeacherId);
|
|
}
|
|
|
|
@PostMapping("editClassSecondTeacher")
|
|
public void editClassSecondTeacher(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer secondTeacherId) {
|
|
schClassService.editClassSecondTeacher(UserContext.getCurrentUserInfo(),id,secondTeacherId);
|
|
}
|
|
|
|
@PostMapping("editClassCampus")
|
|
public void editClassCampus(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer campusId) {
|
|
schClassService.editClassCampus(UserContext.getCurrentUserInfo(),id,campusId);
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("searcHigherSchClass")
|
|
public PageVO<HigherSchClassVO> searcHigherSchClass(UserSysRole curRole,
|
|
@RequestParam(required = false) Integer year,
|
|
@RequestParam(required = false) Integer campusId,
|
|
@RequestParam(required = false) Integer divisionId,
|
|
@RequestParam(required = false) Integer majorsId,
|
|
Pageable pageable) {
|
|
return schClassService.searcHigherSchClass(curRole.getSchId(),year,campusId,divisionId,majorsId,pageable);
|
|
}
|
|
|
|
@PostMapping("saveHigherSchClass")
|
|
public void addHigherSchClass(BoaUser authUserWithDept, UserSysRole curRole,@RequestBody SchClass model) {
|
|
schClassService.saveHigherSchClass(UserContext.getCurrentUserInfo(),model);
|
|
}
|
|
|
|
@PostMapping("delete/{id}")
|
|
public void deleteSchClass(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
|
|
schClassService.deleteSchClass(UserContext.getCurrentUserInfo(),id,curRole.getSchId());
|
|
}
|
|
|
|
|
|
@GetMapping("select")
|
|
public List<SelectIntVO> getClassSelect(UserSysRole curRole, @RequestParam Integer gradeId) {
|
|
return schClassService.getClassSelect(curRole.getSchId(),gradeId);
|
|
}
|
|
|
|
@GetMapping("selectBySchIdAndGradeId")
|
|
public List<SelectIntVO> getClassSelect(@RequestParam Integer schId, @RequestParam Integer gradeId) {
|
|
return schClassService.getClassSelect(schId,gradeId);
|
|
}
|
|
|
|
|
|
@GetMapping("downloadTemplate")
|
|
public void downloadTemplate(HttpServletResponse response,Integer schId) {
|
|
String fileName="班级导入模板";
|
|
List<Map<String, Object>> sheets = new ArrayList<>();
|
|
|
|
List<SchClassExcelColumn> classList=new ArrayList<>();
|
|
{
|
|
SchClassExcelColumn column=new SchClassExcelColumn();
|
|
column.setGradeName("示例:初一");
|
|
column.setClazzName("示例:1班");
|
|
column.setClazzCName("示例:一班");
|
|
column.setBzr("示例:张三");
|
|
classList.add(column);
|
|
}
|
|
|
|
List<String> gradeNames=baseSchsystemGradeService.getGradeSelect(schId,null,null)
|
|
.stream().map(s->s.getName()).collect(Collectors.toList());
|
|
|
|
List<String> teaNames=schTeacherService.getSchTeacherList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
|
|
|
|
List<ImportRuleExcelColumn> ruleList = new ArrayList<>();
|
|
|
|
ImportRuleExcelColumn rule1 = new ImportRuleExcelColumn();
|
|
rule1.setRuleItem("年级");
|
|
rule1.setDescription("必填");
|
|
rule1.setContent(String.join("、",gradeNames));
|
|
ruleList.add(rule1);
|
|
|
|
ImportRuleExcelColumn rule2 = new ImportRuleExcelColumn();
|
|
rule2.setRuleItem("班级");
|
|
rule2.setDescription("必填");
|
|
rule2.setContent("1班、2班、3班~n班");
|
|
ruleList.add(rule2);
|
|
|
|
ImportRuleExcelColumn rule3 = new ImportRuleExcelColumn();
|
|
rule3.setRuleItem("班主任、副班主任");
|
|
rule3.setDescription("选填");
|
|
rule3.setContent(String.join("、",teaNames));
|
|
ruleList.add(rule3);
|
|
|
|
ExportParams params1 = new ExportParams("班级导入",comSchTreeService.getSchoolName(schId));
|
|
Map<String, Object> sheet1 = new HashMap<>();
|
|
sheet1.put("title",params1);
|
|
sheet1.put("entity", SchClassExcelColumn.class);
|
|
sheet1.put("data", classList);
|
|
sheets.add(sheet1);
|
|
|
|
ExportParams params2 = new ExportParams("导入规则", "导入规则");
|
|
|
|
Map<String, Object> sheet2 = new HashMap<>();
|
|
sheet2.put("title", params2);
|
|
sheet2.put("entity", ImportRuleExcelColumn.class);
|
|
sheet2.put("data", ruleList);
|
|
sheets.add(sheet2);
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(sheets, ExcelType.HSSF);
|
|
EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook);
|
|
}
|
|
|
|
@PostMapping("importClasses")
|
|
public void importClasses(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
|
|
schClassService.importClasses(UserContext.getCurrentUserInfo(),file);
|
|
}
|
|
|
|
|
|
@GetMapping("downloadHeightTemplate")
|
|
public void downloadHeightTemplate(HttpServletResponse response,Integer schId) {
|
|
String fileName="班级导入模板";
|
|
List<Map<String, Object>> sheets = new ArrayList<>();
|
|
|
|
List<SchHeightClassExcelColumn> classList=new ArrayList<>();
|
|
{
|
|
SchHeightClassExcelColumn column=new SchHeightClassExcelColumn();
|
|
column.setGradeName("示例:2026级");
|
|
column.setClazzCode("");
|
|
column.setClazzName("示例:南校1班");
|
|
column.setClazzCName("");
|
|
column.setCampus("示例:南校区");
|
|
column.setDivistion("示例:信息工程");
|
|
column.setDivistion("示例:软件开发");
|
|
column.setBzr("示例:张三");
|
|
classList.add(column);
|
|
}
|
|
|
|
|
|
List<String> campusNames=schDicCampusService.getSchDicCampusCacheList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
|
|
|
|
List<String> divisionNames=schDicDivisionService.getSchDicDivisionCacheList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
|
|
|
|
List<String> majorsNames=schDicMajorsService.getSchDicMajorsCacheList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
|
|
|
|
|
|
List<String> teaNames=schTeacherService.getSchTeacherList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
|
|
|
|
List<ImportRuleExcelColumn> ruleList = new ArrayList<>();
|
|
|
|
ImportRuleExcelColumn rule1 = new ImportRuleExcelColumn();
|
|
rule1.setRuleItem("校区");
|
|
rule1.setDescription("选填");
|
|
rule1.setContent(String.join("、",campusNames));
|
|
ruleList.add(rule1);
|
|
|
|
ImportRuleExcelColumn rule2 = new ImportRuleExcelColumn();
|
|
rule2.setRuleItem("系部");
|
|
rule2.setDescription("必填");
|
|
rule2.setContent(String.join("、",divisionNames));
|
|
ruleList.add(rule2);
|
|
|
|
ImportRuleExcelColumn rule3 = new ImportRuleExcelColumn();
|
|
rule3.setRuleItem("专业");
|
|
rule3.setDescription("必填");
|
|
rule3.setContent(String.join("、",majorsNames));
|
|
ruleList.add(rule3);
|
|
|
|
ImportRuleExcelColumn rule4 = new ImportRuleExcelColumn();
|
|
rule4.setRuleItem("班主任");
|
|
rule4.setDescription("选填");
|
|
rule4.setContent(String.join("、",teaNames));
|
|
ruleList.add(rule4);
|
|
|
|
ExportParams params1 = new ExportParams("班级导入",comSchTreeService.getSchoolName(schId));
|
|
Map<String, Object> sheet1 = new HashMap<>();
|
|
sheet1.put("title",params1);
|
|
sheet1.put("entity", SchHeightClassExcelColumn.class);
|
|
sheet1.put("data", classList);
|
|
sheets.add(sheet1);
|
|
|
|
ExportParams params2 = new ExportParams("导入规则", "导入规则");
|
|
|
|
Map<String, Object> sheet2 = new HashMap<>();
|
|
sheet2.put("title", params2);
|
|
sheet2.put("entity", ImportRuleExcelColumn.class);
|
|
sheet2.put("data", ruleList);
|
|
sheets.add(sheet2);
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(sheets, ExcelType.HSSF);
|
|
EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook);
|
|
}
|
|
|
|
@PostMapping("importHeightClasses")
|
|
public void importHeightClasses(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
|
|
schClassService.importHeightClasses(UserContext.getCurrentUserInfo(),file);
|
|
}
|
|
|
|
@GetMapping("backupAllSnapshot")
|
|
public void backupAllSnapshot() {
|
|
schClassService.backupAllSnapshot();
|
|
}
|
|
|
|
@GetMapping("upgradeAllClasses")
|
|
public void upgradeAllClasses() {
|
|
schClassService.upgradeAllClasses();
|
|
}
|
|
|
|
|
|
}
|