refactor: 根包由 com.bestsch.bschclassmanage 重命名为 com.yunhai.bschclassmanage
- 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-* 保持不动)
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
package com.yunhai.bschclassmanage.controller.api;
|
||||
|
||||
|
||||
import com.yunhai.bschclassmanage.config.Config;
|
||||
import com.yunhai.bschclassmanage.controller.BaseController;
|
||||
import com.yunhai.bschclassmanage.entity.SchClassTeach;
|
||||
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
|
||||
import com.yunhai.bschclassmanage.model.vo.*;
|
||||
import com.yunhai.bschclassmanage.service.*;
|
||||
import com.yunhai.bschclassmanage.utils.UserContext;
|
||||
import com.yunhai.platform.utils.model.BoaUser;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping(Config.API_PATH+"/teachs/")
|
||||
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
|
||||
public class SchTeachController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISchClassTeachService schClassTeachService; //使用接口
|
||||
|
||||
@Autowired
|
||||
private ISchDicSubjectService schDicSubjectService; //使用接口
|
||||
|
||||
@Autowired
|
||||
private ISchClassService schClassService; //使用接口
|
||||
|
||||
@Autowired
|
||||
private ISchTeacherService schTeacherService; //使用接口
|
||||
|
||||
@GetMapping("search")
|
||||
public SchTeachMapVO getSchTeachMapVO(UserSysRole curRole,
|
||||
@RequestParam(required = true) Integer schsystemId,
|
||||
@RequestParam(required = false) Integer gradeId) {
|
||||
return schClassTeachService.getSchTeachMapVO(curRole.getSchId(),schsystemId,gradeId);
|
||||
}
|
||||
|
||||
@GetMapping("getSchClassTeach")
|
||||
public List<SchTeachMapIdVO> getSchClassTeachMapVO(UserSysRole curRole, @RequestParam Integer gradeId,@RequestParam Integer classId) {
|
||||
return schClassTeachService.getSchClassTeachMapVO(curRole.getSchId(),gradeId,classId);
|
||||
}
|
||||
|
||||
@PostMapping("save")
|
||||
public void saveTeach(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody SchClassTeach model) {
|
||||
schClassTeachService.saveTeach(UserContext.getCurrentUserInfo(),model);
|
||||
}
|
||||
|
||||
@PostMapping("delete/{id}")
|
||||
public void delTeachById(BoaUser authUserWithDept, UserSysRole curRole, @PathVariable Integer id) {
|
||||
schClassTeachService.delTeachById(UserContext.getCurrentUserInfo(),id);
|
||||
}
|
||||
|
||||
@PostMapping("delClassTeach")
|
||||
public void delClassTeach(BoaUser authUserWithDept, UserSysRole curRole,@RequestParam Integer classId) {
|
||||
schClassTeachService.delClassTeach(UserContext.getCurrentUserInfo(),classId);
|
||||
}
|
||||
|
||||
@PostMapping("delBatch")
|
||||
public void delBatch(BoaUser authUserWithDept, UserSysRole curRole,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) {
|
||||
schClassTeachService.delBatch(UserContext.getCurrentUserInfo(),schsystemId,gradeId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@GetMapping("downloadTemplate")
|
||||
public void downloadTemplate(HttpServletResponse response,@RequestParam Integer schId,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) throws IOException {
|
||||
|
||||
// 2. 获取科目和班级
|
||||
List<SelectStrVO> subList = schDicSubjectService.select(schId, schsystemId);
|
||||
if (subList == null) subList = Collections.emptyList();
|
||||
List<BaseSchClassVO> schClassList = schClassService.searcBaseSchClass(schId, schsystemId, gradeId,null);
|
||||
if (schClassList == null) schClassList = Collections.emptyList();
|
||||
|
||||
// 3. 创建工作簿
|
||||
Workbook workbook = new HSSFWorkbook(); // 或 XSSFWorkbook
|
||||
Sheet sheet = workbook.createSheet("教师任教导入");
|
||||
|
||||
// 4. 构建表头
|
||||
Row headerRow = sheet.createRow(0);
|
||||
int colIdx = 0;
|
||||
headerRow.createCell(colIdx++).setCellValue("年级");
|
||||
headerRow.createCell(colIdx++).setCellValue("班级");
|
||||
for (SelectStrVO sub : subList) {
|
||||
headerRow.createCell(colIdx++).setCellValue(sub.getName());
|
||||
}
|
||||
|
||||
// 5. 填充数据行
|
||||
int rowIdx = 1;
|
||||
for (BaseSchClassVO clzz : schClassList) {
|
||||
Row row = sheet.createRow(rowIdx++);
|
||||
colIdx = 0;
|
||||
row.createCell(colIdx++).setCellValue(clzz.getGradeName());
|
||||
row.createCell(colIdx++).setCellValue(clzz.getName());
|
||||
for (int i = 0; i < subList.size(); i++) {
|
||||
row.createCell(colIdx++).setCellValue("");
|
||||
}
|
||||
}
|
||||
|
||||
// 6. 自动调整列宽(可选)
|
||||
for (int i = 0; i < 2 + subList.size(); i++) {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
|
||||
// 7. 下载
|
||||
String fileName = "教师任教导入模板.xls";
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
@GetMapping("export")
|
||||
public void export(HttpServletResponse response,@RequestParam Integer schId,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) throws IOException {
|
||||
|
||||
// 2. 获取科目和班级
|
||||
List<SelectStrVO> subList = schDicSubjectService.select(schId, schsystemId);
|
||||
if (subList == null) subList = Collections.emptyList();
|
||||
List<BaseSchClassVO> schClassList = schClassService.searcBaseSchClass(schId, schsystemId, gradeId,null);
|
||||
if (schClassList == null) schClassList = Collections.emptyList();
|
||||
Map<Integer,String> schTeacherMap=schTeacherService.toIdAndNameMap(schId);
|
||||
List<SchClassTeach> schClassTeachList=schClassTeachService.getSchClassTeachCacheList(schId,gradeId,null);
|
||||
|
||||
// 3. 创建工作簿
|
||||
Workbook workbook = new HSSFWorkbook(); // 或 XSSFWorkbook
|
||||
Sheet sheet = workbook.createSheet("教师任教导出");
|
||||
|
||||
// 4. 构建表头
|
||||
Row headerRow = sheet.createRow(0);
|
||||
int colIdx = 0;
|
||||
headerRow.createCell(colIdx++).setCellValue("年级");
|
||||
headerRow.createCell(colIdx++).setCellValue("班级");
|
||||
for (SelectStrVO sub : subList) {
|
||||
headerRow.createCell(colIdx++).setCellValue(sub.getName());
|
||||
}
|
||||
|
||||
// 5. 填充数据行
|
||||
int rowIdx = 1;
|
||||
for (BaseSchClassVO clzz : schClassList) {
|
||||
Row row = sheet.createRow(rowIdx++);
|
||||
colIdx = 0;
|
||||
row.createCell(colIdx++).setCellValue(clzz.getGradeName());
|
||||
row.createCell(colIdx++).setCellValue(clzz.getName());
|
||||
for (SelectStrVO sub:subList) {
|
||||
Optional<SchClassTeach> classTeachOpt= schClassTeachList.stream().filter(s->s.getClassId().equals(clzz.getClassId())&&s.getSubId().equals(sub.getId())).findFirst();
|
||||
row.createCell(colIdx++).setCellValue(classTeachOpt.isPresent()?schTeacherMap.get(classTeachOpt.get().getTeaId()):"");
|
||||
}
|
||||
}
|
||||
|
||||
// 6. 自动调整列宽(可选)
|
||||
for (int i = 0; i < 2 + subList.size(); i++) {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
|
||||
// 7. 下载
|
||||
String fileName = "教师任教导出.xls";
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
@PostMapping("importTeach")
|
||||
public void importTeach(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) {
|
||||
schClassTeachService.importTeach(UserContext.getCurrentUserInfo(),file,schsystemId,gradeId);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user