Commit fcf5a12d by 朱莹

教师档案管理

parent 28069916
......@@ -112,7 +112,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers( "/ws/webSocket/**").anonymous()
.antMatchers( "/webSocket/**").anonymous()
.antMatchers("/login", "/register", "/captchaImage").anonymous()
.antMatchers("/wx/user/login","/wx/user/getRoleType/**").permitAll()
.antMatchers("/wx/user/login","/wx/user/getRoleType/**","/teacherFiles/**").permitAll()
.antMatchers("/dd/user/login").permitAll()
.antMatchers( "/common/**").permitAll()
.antMatchers( "/dd/school/**").permitAll()
......
package yangtz.cs.liu.campus.controller.teacherFiles;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
......@@ -14,7 +15,9 @@ import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesNotice;
import yangtz.cs.liu.campus.service.teacherFiles.ITeacherFilesService;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 教师档案Controller
......@@ -62,10 +65,11 @@ public class TeacherFilesController extends BaseController
/**
* 老师查看自己的档案任务
*/
@GetMapping("getTeachList/{userId}")
public TableDataInfo teachList(@PathVariable("userId") Long userId){
@GetMapping("/getTeachList")
public TableDataInfo teachList(TeacherFiles teacherFiles){
startPage();
List<TeacherFilesNotice> teacherFilesNotices = teacherFilesService.selctTeacherByUserId(userId);
Map map = new HashMap();
List<TeacherFilesNotice> teacherFilesNotices = teacherFilesService.selctTeacherByUserId(teacherFiles);
return getDataTable(teacherFilesNotices);
}
......
......@@ -11,8 +11,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesNotice;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesNoticeTotal;
import yangtz.cs.liu.campus.service.impl.teacherFiles.TeacherFilesExcelUtil;
import yangtz.cs.liu.campus.service.teacherFiles.ITeacherFilesNoticeService;
import javax.annotation.security.DenyAll;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -29,6 +32,9 @@ public class TeacherFilesNoticeController extends BaseController
@Autowired
private ITeacherFilesNoticeService teacherFilesNoticeService;
@Autowired
private TeacherFilesExcelUtil teacherFilesExcelUtil;
/**
* 查询教师档案通知列表
*/
......@@ -45,14 +51,11 @@ public class TeacherFilesNoticeController extends BaseController
/**
* 导出教师档案通知列表
*/
@PreAuthorize("@ss.hasPermi('teacherFiles:notice:export')")
@Log(title = "教室档案通知", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@GetMapping("/export")
@PermitAll
public void export(HttpServletResponse response, TeacherFilesNotice teacherFilesNotice)
{
List<TeacherFilesNoticeTotal> list = teacherFilesNoticeService.selectTeacherFilesNoticeList(teacherFilesNotice);
ExcelUtil<TeacherFilesNoticeTotal> util = new ExcelUtil<TeacherFilesNoticeTotal>(TeacherFilesNoticeTotal.class);
util.exportExcel(response, list, "教室档案通知数据");
teacherFilesExcelUtil.getExcel(teacherFilesNotice.getId(),response);
}
/**
......
......@@ -104,6 +104,26 @@ public class TeacherFiles extends BaseEntity
private Long gradeTeacherId;
private String userId;
private String noticeName;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getNoticeName() {
return noticeName;
}
public void setNoticeName(String noticeName) {
this.noticeName = noticeName;
}
public Long getGradeTeacherId() {
return gradeTeacherId;
}
......
......@@ -2,12 +2,14 @@ package yangtz.cs.liu.campus.mapper.teacherFiles;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFiles;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesNotice;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesNoticeTotal;
import yangtz.cs.liu.campus.vo.teacherFiles.SchoolClassByGradeVo;
import yangtz.cs.liu.campus.vo.teacherFiles.SchoolGradeByClassVo;
import java.util.List;
import java.util.Map;
/**
* 教师档案通知Mapper接口
......@@ -42,8 +44,7 @@ public interface TeacherFilesNoticeMapper
public int insertTeacherFilesNotice(TeacherFilesNotice teacherFilesNotice);
@Select("SELECT fn.*,tf.state,tf.id as fId from teacher_files tf LEFT JOIN teacher_files_notice fn on fn.id= tf.notice_id WHERE tf.teacher_id = #{userId} and fn.notice_state = 2")
public List<TeacherFilesNotice> selctTeacherByUserId(Long userId);
public List<TeacherFilesNotice> selctTeacherByUserId(TeacherFiles teacherFiles);
/**
* 修改教师档案通知
......
//package yangtz.cs.liu.campus.service.impl.teacherFiles;
//
//import com.ruoyi.common.config.RuoYiConfig;
//import com.ruoyi.common.core.domain.AjaxResult;
//import org.apache.poi.hssf.util.HSSFColor;
//import org.apache.poi.ss.usermodel.*;
//import org.apache.poi.ss.util.CellRangeAddress;
//import org.apache.poi.xssf.usermodel.*;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.io.File;
//import java.io.FileOutputStream;
//import java.text.ParseException;
//import java.util.*;
//
//@Service
//public class TeacherFilesExcelUtil {
//
// @Autowired
// private RuoYiConfig ruoYiConfig;
//
//
//// private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//// private SimpleDateFormat sdfS = new SimpleDateFormat("yyyy年MM月dd日");
//// private SimpleDateFormat sdfMS = new SimpleDateFormat("yyyy年MM月");
//
// public AjaxResult getExcel(String noticeId)
// throws Exception {
// // 创建新的Excel 工作簿
// XSSFWorkbook workbook = new XSSFWorkbook();
// /**
// * 主标题
// */
// XSSFCellStyle mainTitle = workbook.createCellStyle();
// //垂直居中
// mainTitle.setVerticalAlignment(VerticalAlignment.CENTER);
// //水平居中
// mainTitle.setAlignment(HorizontalAlignment.CENTER);
// Font mainfont = workbook.createFont();
// mainfont.setFontHeightInPoints((short) 28);
// mainTitle.setFont(mainfont);
//
// /**
// * 标题
// */
// XSSFCellStyle datetitle = workbook.createCellStyle();
// //垂直居中
// datetitle.setVerticalAlignment(VerticalAlignment.CENTER);
// Font datefont = workbook.createFont();
// datefont.setFontHeightInPoints((short) 14);
// datetitle.setFont(datefont);
//
// /**
// * 标题
// */
// XSSFCellStyle title = workbook.createCellStyle();
// //垂直居中
// title.setVerticalAlignment(VerticalAlignment.CENTER);
// //水平居中
// title.setAlignment(HorizontalAlignment.CENTER);
// Font font0 = workbook.createFont();
// font0.setFontHeightInPoints((short) 16);
// font0.setBold(true);
// title.setFont(font0);
// title.setBorderBottom(BorderStyle.THIN); //下边框
// title.setBorderLeft(BorderStyle.THIN);//左边框
// title.setBorderTop(BorderStyle.THIN);//上边框
// title.setBorderRight(BorderStyle.THIN);//右边框
//
// /**
// * 正常格
// */
// XSSFCellStyle cellStyle = workbook.createCellStyle();
// //垂直居中
// cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// //水平居中
// cellStyle.setAlignment(HorizontalAlignment.CENTER);
// cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
// cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
// cellStyle.setBorderTop(BorderStyle.THIN);//上边框
// cellStyle.setBorderRight(BorderStyle.THIN);//右边框
// cellStyle.setWrapText(true);
// Font font = workbook.createFont();
// font.setFontHeightInPoints((short) 12);
// cellStyle.setFont(font);
//
// /**
// * 黄背景格
// */
// XSSFCellStyle yellowFont = workbook.createCellStyle();
// yellowFont.setWrapText(true);
// yellowFont.setFillForegroundColor(HSSFColor.HSSFColorPredefined.GOLD.getIndex());
// yellowFont.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// //垂直居中
// yellowFont.setVerticalAlignment(VerticalAlignment.CENTER);
// //水平居中
// yellowFont.setAlignment(HorizontalAlignment.CENTER);
// yellowFont.setBorderBottom(BorderStyle.THIN); //下边框
// yellowFont.setBorderLeft(BorderStyle.THIN);//左边框
// yellowFont.setBorderTop(BorderStyle.THIN);//上边框
// yellowFont.setBorderRight(BorderStyle.THIN);//右边框
// yellowFont.setFont(font);
//
// /**
// * 红字体格
// */
// XSSFCellStyle redFont = workbook.createCellStyle();
// //垂直居中
// redFont.setVerticalAlignment(VerticalAlignment.CENTER);
// //水平居中
// redFont.setAlignment(HorizontalAlignment.CENTER);
// Font font1 = workbook.createFont();
// font1.setColor(HSSFColor.HSSFColorPredefined.DARK_RED.getIndex());
// font1.setFontHeightInPoints((short) 12);
// redFont.setFont(font1);
// redFont.setBorderBottom(BorderStyle.THIN); //下边框
// redFont.setBorderLeft(BorderStyle.THIN);//左边框
// redFont.setBorderTop(BorderStyle.THIN);//上边框
// redFont.setBorderRight(BorderStyle.THIN);//右边框
//
// List<Long> depaList = getDepaList(request.getDepartment());
// /**
// * 时间集合
// */
// List<AttendanceDatePoi> dateDes = getDateDes(request.getStartTime(), request.getEndTime());
//
// for (int t = 0; t < dateDes.size(); t++) {
//
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(dateDes.get(t).getStartDate());
// int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
// int month = calendar.get(Calendar.MONTH);
// int year = calendar.get(Calendar.YEAR);
//
// XSSFSheet sheet = workbook.createSheet();
// workbook.setSheetName(t, dateDes.get(t).getMonth());
// /**
// * 第一行
// */
// XSSFRow row0 = sheet.createRow(0);
// row0.setHeightInPoints(51);
// sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 4 + actualMaximum));
// XSSFCell cell0 = row0.createCell(0);
// cell0.setCellStyle(mainTitle);
// cell0.setCellValue("考勤表");
//
// /**
// * 第二行
// */
// XSSFRow row1 = sheet.createRow(1);
// sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 4));
// XSSFCell cel1 = row1.createCell(0);
// cel1.setCellStyle(datetitle);
// cel1.setCellValue(sdfS.format(dateDes.get(t).getStartDate()) + "-" + sdfS.format(dateDes.get(t).getEndDate()));
//
// XSSFCell cel22 = row1.createCell(actualMaximum - 11);
// cel22.setCellValue("√");
// XSSFCell cel33 = row1.createCell(actualMaximum - 10);
// cel33.setCellValue("出勤");
// XSSFCell cel2 = row1.createCell(actualMaximum - 9);
// cel2.setCellValue("●");
// XSSFCell cel3 = row1.createCell(actualMaximum - 8);
// cel3.setCellValue("未签到");
// XSSFCell cel4 = row1.createCell(actualMaximum - 7);
// cel4.setCellValue("□");
// XSSFCell cel5 = row1.createCell(actualMaximum - 6);
// cel5.setCellValue("事假");
// XSSFCell cel6 = row1.createCell(actualMaximum - 5);
// cel6.setCellValue("☆");
// XSSFCell cel7 = row1.createCell(actualMaximum - 4);
// cel7.setCellValue("节假日");
// XSSFCell cel8 = row1.createCell(actualMaximum - 3);
// cel8.setCellValue("△");
// XSSFCell cel9 = row1.createCell(actualMaximum - 2);
// cel9.setCellValue("迟到");
// XSSFCell cel10 = row1.createCell(actualMaximum - 1);
// cel10.setCellValue("○");
// XSSFCell cel11 = row1.createCell(actualMaximum);
// cel11.setCellValue("早退");
// XSSFCell cel12 = row1.createCell(actualMaximum + 1);
// cel12.setCellValue("×");
// XSSFCell cel13 = row1.createCell(actualMaximum + 2);
// cel13.setCellValue("旷工");
// XSSFCell cel14 = row1.createCell(actualMaximum + 3);
// cel14.setCellValue("#");
// XSSFCell cel15 = row1.createCell(actualMaximum + 4);
// cel15.setCellValue("外勤");
// /**
// * 第三行
// */
// XSSFRow row2 = sheet.createRow(2);
// XSSFCell cell = row2.createCell(0);
// cell.setCellValue("序号");
// cell.setCellStyle(title);
// sheet.setColumnWidth(0, 34 * 45);
//
//
// XSSFCell cell1 = row2.createCell(1);
// cell1.setCellValue("姓名");
// cell1.setCellStyle(title);
// sheet.setColumnWidth(1, 34 * 65);
//
// XSSFCell cell2 = row2.createCell(2);
// cell2.setCellValue("科室名");
// cell2.setCellStyle(title);
// sheet.setColumnWidth(2, 34 * 75);
//
// XSSFCell cell3 = row2.createCell(3);
// cell3.setCellValue("签到异常天数");
// cell3.setCellStyle(title);
// sheet.setColumnWidth(3, 34 * 130);
//
// XSSFCell cell4 = row2.createCell(4);
// cell4.setCellValue("事假");
// cell4.setCellStyle(title);
// sheet.setColumnWidth(4, 34 * 45);
//
// for (int i = 1; i <= actualMaximum; i++) {
// XSSFCell cell5 = row2.createCell(4 + i);
// cell5.setCellValue(i);
// cell5.setCellStyle(title);
// sheet.setColumnWidth(4 + i, 34 * 34);
// }
//
// /**
// * 职工集合
// */
// int x = 3;
// int id = 1;
// for (Long depaid : depaList) {
// System.out.println("查询"+depaid);
// List<XxdjEmployees> xxdjEmployeesList = employeesMapper.SelectByDepartment(String.valueOf(depaid));
// System.out.println("职工集合查询"+xxdjEmployeesList);
// Dept dept = deptMapper.selectDeptById(depaid);
// for (XxdjEmployees xxdjEmployees : xxdjEmployeesList) {
// XSSFRow xrow1 = sheet.createRow(x);
// XSSFRow xrow2 = sheet.createRow(x + 1);
// XSSFRow xrow3 = sheet.createRow(x + 2);
// XSSFRow xrow4 = sheet.createRow(x + 3);
// //序号
// XSSFCell xcell0 = xrow1.createCell(0);
// XSSFCell x2cell0 = xrow2.createCell(0);
// XSSFCell x3cell0 = xrow3.createCell(0);
// XSSFCell x4cell0 = xrow4.createCell(0);
// xcell0.setCellStyle(cellStyle);
// x2cell0.setCellStyle(cellStyle);
// x3cell0.setCellStyle(cellStyle);
// x4cell0.setCellStyle(cellStyle);
// xcell0.setCellValue(id);
// //姓名
// XSSFCell xcell1 = xrow1.createCell(1);
// XSSFCell x2cell1 = xrow2.createCell(1);
// XSSFCell x3cell1 = xrow3.createCell(1);
// XSSFCell x4cell1 = xrow4.createCell(1);
// xcell1.setCellStyle(cellStyle);
// x2cell1.setCellStyle(cellStyle);
// x3cell1.setCellStyle(cellStyle);
// x4cell1.setCellStyle(cellStyle);
// xcell1.setCellValue(xxdjEmployees.getName());
// //科室名
// XSSFCell xcell2 = xrow1.createCell(2);
// XSSFCell x2cell2 = xrow2.createCell(2);
// XSSFCell x3cell2 = xrow3.createCell(2);
// XSSFCell x4cell2 = xrow4.createCell(2);
// xcell2.setCellStyle(cellStyle);
// x2cell2.setCellStyle(cellStyle);
// x3cell2.setCellStyle(cellStyle);
// x4cell2.setCellStyle(cellStyle);
// xcell2.setCellValue(dept.getDeptName());
// //签到异常天数
// XSSFCell xcell3 = xrow1.createCell(3);
// XSSFCell x2cell3 = xrow2.createCell(3);
// XSSFCell x3cell3 = xrow3.createCell(3);
// XSSFCell x4cell3 = xrow4.createCell(3);
// xcell3.setCellStyle(cellStyle);
// x2cell3.setCellStyle(cellStyle);
// x3cell3.setCellStyle(cellStyle);
// x4cell3.setCellStyle(cellStyle);
// //事假
// XSSFCell xcell4 = xrow1.createCell(4);
// XSSFCell x2cell4 = xrow2.createCell(4);
// XSSFCell x3cell4 = xrow3.createCell(4);
// XSSFCell x4cell4 = xrow4.createCell(4);
// xcell4.setCellStyle(redFont);
// x2cell4.setCellStyle(redFont);
// x3cell4.setCellStyle(redFont);
// x4cell4.setCellStyle(redFont);
//
// sheet.addMergedRegion(new CellRangeAddress(x, x + 3, 0, 0));
// sheet.addMergedRegion(new CellRangeAddress(x, x + 3, 1, 1));
// sheet.addMergedRegion(new CellRangeAddress(x, x + 3, 2, 2));
// sheet.addMergedRegion(new CellRangeAddress(x, x + 3, 3, 3));
// sheet.addMergedRegion(new CellRangeAddress(x, x + 3, 4, 4));
//
// String idcard = xxdjEmployees.getIdcard();
// if (idcard != null && !"".equals(idcard)) {
// Map map = new HashMap();
// map.put("idCard", idcard);
// map.put("startDay", sdf.format(dateDes.get(t).getStartDate()));
// map.put("endDay", sdf.format(dateDes.get(t).getEndDate()));
// List<XxdjAttendance> xxdjAttendances = attendanceMapper.selectMonth(map);
// Map<String, XxdjAttendance> attendanceMap = new HashMap();
// for (XxdjAttendance xxdjAttendance : xxdjAttendances) {
// attendanceMap.put(xxdjAttendance.getAttendanceDay(), xxdjAttendance);
// }
// int leaveDate = 0;
// int errorDate = 0;
// for (int i = 1; i <= actualMaximum; i++) {
// XSSFCell xcell5 = xrow1.createCell(4 + i);
// XSSFCell x2cell5 = xrow2.createCell(4 + i);
// XSSFCell x3cell5 = xrow3.createCell(4 + i);
// XSSFCell x4cell5 = xrow4.createCell(4 + i);
// Calendar xcalendar = Calendar.getInstance();
// xcalendar.set(year, month, i);
// int weekDay = xcalendar.get(Calendar.DAY_OF_WEEK);
// if (weekDay == 7 || weekDay == 1) {
// xcell5.setCellStyle(yellowFont);
// x2cell5.setCellStyle(yellowFont);
// x3cell5.setCellStyle(yellowFont);
// x4cell5.setCellStyle(yellowFont);
// } else {
// xcell5.setCellStyle(cellStyle);
// x2cell5.setCellStyle(cellStyle);
// x3cell5.setCellStyle(cellStyle);
// x4cell5.setCellStyle(cellStyle);
// }
// XxdjAttendance xxdjAttendance = attendanceMap.get(sdf.format(xcalendar.getTime()));
// if (xxdjAttendance != null) {
// xcell5.setCellValue(toFHstate(xxdjAttendance.getForenoonStart()) + toFHoutside(xxdjAttendance.getForenoonStartOutside()));
// x2cell5.setCellValue(toFHstate(xxdjAttendance.getForenoonEnd()) + toFHoutside(xxdjAttendance.getForenoonEndOutside()));
// x3cell5.setCellValue(toFHstate(xxdjAttendance.getAfternoonStart()) + toFHoutside(xxdjAttendance.getAfternoonStartOutside()));
// x4cell5.setCellValue(toFHstate(xxdjAttendance.getAfternoonEnd()) + toFHoutside(xxdjAttendance.getAfternoonEndOutside()));
// if ("1".equals(xxdjAttendance.getLeaveDate())) {
// leaveDate++;
// }
// if ("1".equals(xxdjAttendance.getErrorDate())) {
// errorDate++;
// }
//
// }
// }
// xcell3.setCellValue(errorDate);
// xcell4.setCellValue(leaveDate);
//
// }
// x = x + 4;
// id++;
// }
// }
// }
//
// FileOutputStream fos = new FileOutputStream(getAbsoluteFile("签到表.xlsx"));
// // 把相应的Excel 工作簿存盘
// workbook.write(fos);
// fos.flush();
// // 操作结束,关闭文件
// fos.close();
// return AjaxResult.success("签到表.xlsx");
// }
//
// /**
// * 获取下载路径
// *
// * @param filename 文件名称
// */
// public String getAbsoluteFile(String filename) {
// String downloadPath = ruoYiConfig.getDownloadPath() + filename;
// File desc = new File(downloadPath);
// if (!desc.getParentFile().exists()) {
// desc.getParentFile().mkdirs();
// }
// return downloadPath;
// }
//
// //(1.正常 2.迟到 3.早退 4.请假 5.未签到 6.节假日 7.旷工)
// private String toFHstate(String state) {
// if (state == null) {
// return "●";
// }
// switch (state) {
// case "1":
// return "√";
// case "2":
// return "△";
// case "3":
// return "○";
// case "4":
// return "□";
// case "6":
// return "☆";
// case "7":
// return "×";
// default:
// return "●";
// }
// }
//
// private String toFHoutside(String outside) {
// if (outside == null) {
// return "";
// }
// switch (outside) {
// case "1":
// return "#";
// default:
// return "";
// }
// }
//
// public List<AttendanceDatePoi> getDateDes(String startDate, String endDate) {
// List<AttendanceDatePoi> datePois = new ArrayList<>();
// try {
//
// Date start = sdf.parse(startDate);
// Date end = sdf.parse(endDate);
// Calendar startCalendar = Calendar.getInstance();
// startCalendar.setTime(start);
// int startYear = startCalendar.get(Calendar.YEAR);
// int startMonth = startCalendar.get(Calendar.MONTH);
// int startDay = startCalendar.get(Calendar.DAY_OF_MONTH);
// Calendar endCalendar = Calendar.getInstance();
// endCalendar.setTime(end);
// int endYear = endCalendar.get(Calendar.YEAR);
// int endMonth = endCalendar.get(Calendar.MONTH);
// int endDay = endCalendar.get(Calendar.DAY_OF_MONTH);
// for (int year = startYear; year <= endYear; year++) {
//
// if (year != startYear)
// startMonth = 1;
// int maxMonth = 12;
// if (year == endYear) {
// maxMonth = endMonth;
// }
// for (int month = startMonth; month <= maxMonth; month++) {
// Calendar calendar = Calendar.getInstance();
// calendar.set(Calendar.YEAR, year);
// calendar.set(Calendar.MONTH, month);
// int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
// AttendanceDatePoi datePoi = new AttendanceDatePoi();
// if (month != startMonth)
// startDay = 1;
// if (month == endMonth && year == endYear)
// actualMaximum = endDay;
// datePoi.setMonth(sdfMS.format(calendar.getTime()));
// calendar.set(Calendar.DAY_OF_MONTH, startDay);
// datePoi.setStartDate(calendar.getTime());
// calendar.set(Calendar.DAY_OF_MONTH, actualMaximum);
// datePoi.setEndDate(calendar.getTime());
// datePois.add(datePoi);
// }
// }
// } catch (ParseException e) {
// e.printStackTrace();
// }
// return datePois;
// }
//
// //获取 单位id集合
// public List<Long> getDepaList(Long department) {
// List<Long> depaList = new ArrayList<>();
// List<Dept> depts = deptMapper.selectChildrenDeptById(department);
// if (depts == null || depts.size() == 0) {
// depaList.add(department);
// } else {
// for (Dept dept : depts) {
// List<Long> todepaList = getDepaList(dept.getDeptId());
// depaList.addAll(todepaList);
// }
// }
// return depaList;
// }
//}
package yangtz.cs.liu.campus.service.impl.teacherFiles;
import com.ruoyi.common.config.RuoYiConfig;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFiles;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesVO;
import yangtz.cs.liu.campus.service.teacherFiles.ITeacherFilesService;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class TeacherFilesExcelUtil {
@Autowired
private RuoYiConfig ruoYiConfig;
@Autowired
private ITeacherFilesService teacherFilesService;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
public void getExcel(String noticeId, HttpServletResponse response) {
TeacherFiles teacherFiles = new TeacherFiles();
teacherFiles.setNoticeId(noticeId);
List<TeacherFiles> teacherFilesList = teacherFilesService.selectTeacherFilesList(teacherFiles);
// 创建新的Excel 工作簿
XSSFWorkbook workbook = new XSSFWorkbook();
/**
* 主标题
*/
XSSFCellStyle mainTitle = workbook.createCellStyle();
//垂直居中
mainTitle.setVerticalAlignment(VerticalAlignment.CENTER);
//水平居中
mainTitle.setAlignment(HorizontalAlignment.CENTER);
Font mainfont = workbook.createFont();
mainfont.setFontHeightInPoints((short) 12);
mainfont.setBold(true);
mainTitle.setFont(mainfont);
mainTitle.setBorderBottom(BorderStyle.THIN); //下边框
mainTitle.setBorderLeft(BorderStyle.THIN);//左边框
mainTitle.setBorderTop(BorderStyle.THIN);//上边框
mainTitle.setBorderRight(BorderStyle.THIN);//右边框
/**
* 正文
*/
XSSFCellStyle title = workbook.createCellStyle();
//垂直居中
title.setVerticalAlignment(VerticalAlignment.CENTER);
//水平居中
title.setAlignment(HorizontalAlignment.CENTER);
Font font0 = workbook.createFont();
font0.setFontHeightInPoints((short) 12);
title.setFont(font0);
title.setBorderBottom(BorderStyle.THIN); //下边框
title.setBorderLeft(BorderStyle.THIN);//左边框
title.setBorderTop(BorderStyle.THIN);//上边框
title.setBorderRight(BorderStyle.THIN);//右边框
for (int t = 0; t < teacherFilesList.size(); t++) {
TeacherFilesVO files = teacherFilesService.selectTeacherFilesById(teacherFilesList.get(t).getId());
XSSFSheet sheet = workbook.createSheet();
workbook.setSheetName(t, files.getTeacherName()+t);
/**
* 第一行
*/
XSSFRow row0 = sheet.createRow(0);
row0.setHeightInPoints(34);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 5));
XSSFCell cell0 = row0.createCell(0);
cell0.setCellStyle(mainTitle);
cell0.setCellValue("基本信息");
sheet.setColumnWidth(0, 34 * 140);
sheet.setColumnWidth(1, 34 * 100);
sheet.setColumnWidth(2, 34 * 100);
sheet.setColumnWidth(3, 34 * 140);
sheet.setColumnWidth(4, 34 * 100);
sheet.setColumnWidth(5, 34 * 100);
/**
* 第二行
*/
for(int i=1;i<=8;i++){
XSSFRow row2 = sheet.createRow(i);
row2.setHeightInPoints(20);
XSSFCell cell = row2.createCell(0);
String cellValue1 = "";
switch (i){
case 1:
cellValue1="学年学期";
break;
case 2:
cellValue1="姓名";
break;
case 3:
cellValue1="年龄";
break;
case 4:
cellValue1="学历";
break;
case 5:
cellValue1="任教学科";
break;
case 6:
cellValue1="任正班主任班级";
break;
case 7:
cellValue1="是否教学组长";
break;
case 8:
cellValue1="设计课时量";
break;
}
cell.setCellValue(cellValue1);
cell.setCellStyle(title);
sheet.addMergedRegion(new CellRangeAddress(i, i, 1, 2));
XSSFCell cell1 = row2.createCell(1);
String cellValue2 = "";
switch (i){
case 1:
cellValue2=files.getFilesSemester();
break;
case 2:
cellValue2=files.getTeacherName();
break;
case 3:
if(files.getAge()!=null){
cellValue2=String.valueOf(files.getAge());
}
break;
case 4:
cellValue2=files.getEducation();
break;
case 5:
cellValue2=files.getCourseName();
break;
case 6:
cellValue2=files.getBzrClassName();
break;
case 7:
cellValue2=files.getIsTeachingGroupLeader();
break;
case 8:
if(files.getClassHour()!=null){
cellValue2=String.valueOf(files.getClassHour());
}
break;
}
cell1.setCellValue(cellValue2);
cell1.setCellStyle(title);
XSSFCell cell3 = row2.createCell(2);
cell3.setCellStyle(title);
XSSFCell cell2 = row2.createCell(3);
String cellValue3 = "";
switch (i){
case 1:
cellValue3="级部";
break;
case 2:
cellValue3="性别";
break;
case 3:
cellValue3="职称";
break;
case 4:
cellValue3="政治面貌";
break;
case 5:
cellValue3="任教班级";
break;
case 6:
cellValue3="任副班主任班级";
break;
case 7:
cellValue3="是否教研组长";
break;
case 8:
cellValue3="班主任情况";
break;
}
cell2.setCellValue(cellValue3);
cell2.setCellStyle(title);
sheet.addMergedRegion(new CellRangeAddress(i, i, 4, 5));
XSSFCell cell4 = row2.createCell(4);
String cellValue4 = "";
switch (i){
case 1:
cellValue4=files.getGradeName();
break;
case 2:
if(files.getSex()!=null){
if(files.getSex().equals("0")){
cellValue4="男";
}else{
cellValue4="女";
}
}
break;
case 3:
cellValue4=files.getTitle();
break;
case 4:
cellValue4=files.getAppearance();
break;
case 5:
cellValue4=files.getClassName();
break;
case 6:
cellValue4=files.getFbzrClassName();
break;
case 7:
cellValue4=files.getIsResearchGroupLeader();
break;
case 8:
cellValue4=files.getClassTeacherDetails();
break;
}
cell4.setCellValue(cellValue4);
cell4.setCellStyle(title);
XSSFCell cell5 = row2.createCell(5);
cell5.setCellStyle(title);
}
}
// 把相应的Excel 工作簿存盘
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
try {
workbook.write(response.getOutputStream());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* 获取下载路径
*
* @param filename 文件名称
*/
public String getAbsoluteFile(String filename) {
String downloadPath = ruoYiConfig.getDownloadPath() + filename;
File desc = new File(downloadPath);
if (!desc.getParentFile().exists()) {
desc.getParentFile().mkdirs();
}
return downloadPath;
}
}
......@@ -76,8 +76,8 @@ public class TeacherFilesServiceImpl implements ITeacherFilesService
@Override
public List<TeacherFilesNotice> selctTeacherByUserId(Long userId) {
return teacherFilesNoticeMapper.selctTeacherByUserId(userId);
public List<TeacherFilesNotice> selctTeacherByUserId(TeacherFiles teacherFiles) {
return teacherFilesNoticeMapper.selctTeacherByUserId(teacherFiles);
}
/**
......
......@@ -5,6 +5,7 @@ import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesNotice;
import yangtz.cs.liu.campus.domain.teacherFiles.TeacherFilesVO;
import java.util.List;
import java.util.Map;
/**
* 教师档案Service接口
......@@ -29,7 +30,7 @@ public interface ITeacherFilesService
* @return 教师档案集合
*/
public List<TeacherFiles> selectTeacherFilesList(TeacherFiles teacherFiles);
public List<TeacherFilesNotice> selctTeacherByUserId(Long userId);
public List<TeacherFilesNotice> selctTeacherByUserId(TeacherFiles teacherFiles);
/**
* 新增教师档案
......
......@@ -63,6 +63,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTeacherFilesNoticeVo"/>
where id = #{id}
</select>
<select id="selctTeacherByUserId" parameterType="TeacherFiles" resultType="TeacherFilesNotice">
SELECT fn.*,tf.state,tf.id as fId from teacher_files tf LEFT JOIN teacher_files_notice fn on fn.id= tf.notice_id WHERE tf.teacher_id = #{userId} and fn.notice_name LIKE concat('%', #{noticeName}, '%') and fn.notice_state = 2
</select>
<insert id="insertTeacherFilesNotice" parameterType="TeacherFilesNotice">
insert into teacher_files_notice
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment