|
@@ -12,6 +12,8 @@ import com.ssj.api.domain.vo.teacher.TeacherAddReq;
|
|
|
import com.ssj.api.domain.vo.teacher.TeacherChangeReq;
|
|
|
import com.ssj.api.domain.vo.teacher.TeacherDelReq;
|
|
|
import com.ssj.api.domain.vo.teacher.TeacherReq;
|
|
|
+import com.ssj.bean.common.framework.core.domain.Response;
|
|
|
+import com.ssj.bean.sys.imlibuser.TbClassStudentTemp;
|
|
|
import com.ssj.bean.sys.imlibuser.TbClassTeacherTemp;
|
|
|
import com.ssj.bean.weixin.libmy.domain.TbLibManager;
|
|
|
import com.ssj.framework.core.common.controller.BaseController;
|
|
@@ -19,7 +21,6 @@ import com.ssj.framework.core.util.Constant;
|
|
|
import com.ssj.framework.core.util.PasswordUtil;
|
|
|
import com.ssj.framework.core.util.ResponseConstant;
|
|
|
import com.ssj.framework.core.util.ResponseEntity;
|
|
|
-import com.ssj.framework.weixin.util.DateUtil;
|
|
|
import com.ssj.service.kmt.correctsys.dto.HomeworkPictureCheckDto;
|
|
|
import com.ssj.service.kmt.correctsys.service.KmtCorrectSysService;
|
|
|
import com.ssj.service.sys.homework.service.HomeworkPictureService;
|
|
@@ -27,17 +28,23 @@ import com.ssj.service.sys.imlibuser.service.TbClassTeacherTempService;
|
|
|
import com.ssj.service.weixin.library.service.IBookManagerService;
|
|
|
import com.ssj.service.weixin.user.service.UserService;
|
|
|
import com.ssj.statistics.service.IStatisticsService;
|
|
|
+import com.ssj.statistics.service.ITeacherEnrollment;
|
|
|
import com.ssj.statistics.service.ITeacherPayService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -66,6 +73,9 @@ public class ApiManagerTeacherController extends BaseController {
|
|
|
@Autowired
|
|
|
private KmtCorrectSysService kmtCorrectSysService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ITeacherEnrollment teacherEnrollment;
|
|
|
+
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "获取平台批改老师列表接口", notes = "获取平台批改老师列表接口")
|
|
@@ -456,12 +466,14 @@ public class ApiManagerTeacherController extends BaseController {
|
|
|
private List<Map<String,Object>> getSalaryList(String userId){
|
|
|
//计算今天日期
|
|
|
LocalDate date = LocalDate.now();
|
|
|
- int day = date.getDayOfMonth();
|
|
|
- LocalTime time = LocalTime.now();
|
|
|
- boolean lastMonth = day< 4 || (day==4 && time.getHour()<12);
|
|
|
- LocalDate localDate = lastMonth?date.minusMonths(2):date.minusMonths(1);
|
|
|
- int month = localDate.getMonthValue();
|
|
|
- int year = localDate.getYear();
|
|
|
+// int day = date.getDayOfMonth();
|
|
|
+// LocalTime time = LocalTime.now();
|
|
|
+// boolean lastMonth = day< 4 || (day==4 && time.getHour()<12);
|
|
|
+// LocalDate localDate = lastMonth?date.minusMonths(2):date.minusMonths(1);
|
|
|
+// int month = localDate.getMonthValue();
|
|
|
+// int year = localDate.getYear();
|
|
|
+ int month = date.getMonthValue();
|
|
|
+ int year = date.getYear();
|
|
|
return teacherPayService.salaryList(userId,month,year);
|
|
|
}
|
|
|
|
|
@@ -482,4 +494,84 @@ public class ApiManagerTeacherController extends BaseController {
|
|
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
response.setCharacterEncoding("utf-8");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册老师信息导入
|
|
|
+ * @param model
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value="/registerTeacherImport")
|
|
|
+ @ResponseBody
|
|
|
+ public Response registerTeacherImport(Model model, @RequestParam("file") MultipartFile file) {
|
|
|
+ Response response = new Response();
|
|
|
+ try {
|
|
|
+ List<Map<String,String>> datas=analysisExFile(file);
|
|
|
+ if(datas!=null && datas.size()>0){
|
|
|
+ teacherEnrollment.registerTeacherImport(datas);
|
|
|
+ }
|
|
|
+ response.success("导入成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("异常", e);
|
|
|
+ response.failure("导入异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * ----------------解析文档相关功能-----------------------
|
|
|
+ */
|
|
|
+
|
|
|
+ public static List<Map<String,String>> analysisExFile(MultipartFile file) throws Exception {
|
|
|
+ List<Map<String,String>> datas=new ArrayList<Map<String,String>>();
|
|
|
+ Map<String,String> map=null;
|
|
|
+
|
|
|
+ @SuppressWarnings("resource")
|
|
|
+ Workbook wb = new XSSFWorkbook(file.getInputStream());
|
|
|
+ Sheet sheet = wb.getSheetAt(0);
|
|
|
+ Row row = null;
|
|
|
+ Cell cell = null;
|
|
|
+ for (Iterator<Row> it = sheet.rowIterator(); it.hasNext();) {
|
|
|
+ map=new LinkedHashMap<String, String>();
|
|
|
+ row = it.next();
|
|
|
+ if (row == null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(row.getRowNum()<=0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(getValue(row.getCell(0)))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (Iterator<Cell> cit =row.cellIterator(); cit.hasNext();) {
|
|
|
+ cell = cit.next();
|
|
|
+ if (cell == null) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(getValue(cell))){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ map.put("data_"+cell.getColumnIndex(), getValue(cell));
|
|
|
+ }
|
|
|
+ datas.add(map);
|
|
|
+ }
|
|
|
+ return datas;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getValue(Cell cell){
|
|
|
+ if(cell==null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()){
|
|
|
+ if(DateUtil.isCellDateFormatted(cell)){
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); //设置转成的时间格式
|
|
|
+ Date date = cell.getDateCellValue();//取得的是date类型
|
|
|
+ String datestr = sdf.format(date);//这里是转成String类型了,要哪种按个人需求
|
|
|
+ return datestr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cell.setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ String text=cell.getStringCellValue()!=null ? String.valueOf(cell.getStringCellValue()):"";
|
|
|
+ return text.trim();
|
|
|
+ }
|
|
|
}
|