|
@@ -1,5 +1,9 @@
|
|
package com.ssj.api.controller;
|
|
package com.ssj.api.controller;
|
|
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
|
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
|
|
+import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.ssj.api.domain.vo.statistics.HomeworkReq;
|
|
import com.ssj.api.domain.vo.statistics.HomeworkReq;
|
|
import com.ssj.api.domain.vo.statistics.ListReq;
|
|
import com.ssj.api.domain.vo.statistics.ListReq;
|
|
@@ -14,17 +18,26 @@ import com.ssj.framework.core.util.Constant;
|
|
import com.ssj.framework.core.util.PasswordUtil;
|
|
import com.ssj.framework.core.util.PasswordUtil;
|
|
import com.ssj.framework.core.util.ResponseConstant;
|
|
import com.ssj.framework.core.util.ResponseConstant;
|
|
import com.ssj.framework.core.util.ResponseEntity;
|
|
import com.ssj.framework.core.util.ResponseEntity;
|
|
|
|
+import com.ssj.framework.weixin.util.DateUtil;
|
|
import com.ssj.service.sys.homework.service.HomeworkPictureService;
|
|
import com.ssj.service.sys.homework.service.HomeworkPictureService;
|
|
import com.ssj.service.sys.imlibuser.service.TbClassTeacherTempService;
|
|
import com.ssj.service.sys.imlibuser.service.TbClassTeacherTempService;
|
|
import com.ssj.service.weixin.library.service.IBookManagerService;
|
|
import com.ssj.service.weixin.library.service.IBookManagerService;
|
|
import com.ssj.service.weixin.user.service.UserService;
|
|
import com.ssj.service.weixin.user.service.UserService;
|
|
import com.ssj.statistics.service.IStatisticsService;
|
|
import com.ssj.statistics.service.IStatisticsService;
|
|
|
|
+import com.ssj.statistics.service.ITeacherPayService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.time.LocalTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@Api(value = "平台批改老师相关", tags = "平台批改老师相关")
|
|
@Api(value = "平台批改老师相关", tags = "平台批改老师相关")
|
|
@@ -44,6 +57,9 @@ public class ApiManagerTeacherController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private IStatisticsService statisticsService;
|
|
private IStatisticsService statisticsService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ITeacherPayService teacherPayService;
|
|
|
|
+
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
@ApiOperation(value = "获取平台批改老师列表接口", notes = "获取平台批改老师列表接口")
|
|
@ApiOperation(value = "获取平台批改老师列表接口", notes = "获取平台批改老师列表接口")
|
|
@@ -252,13 +268,110 @@ public class ApiManagerTeacherController extends BaseController {
|
|
@ApiOperation(value = "作业批改痕迹", notes = "作业批改痕迹")
|
|
@ApiOperation(value = "作业批改痕迹", notes = "作业批改痕迹")
|
|
public ResponseEntity pictureDetail(@RequestParam(name = "accessToken") String accessToken,@RequestBody HomeworkReq req) {
|
|
public ResponseEntity pictureDetail(@RequestParam(name = "accessToken") String accessToken,@RequestBody HomeworkReq req) {
|
|
ResponseEntity responseEntity = new ResponseEntity();
|
|
ResponseEntity responseEntity = new ResponseEntity();
|
|
- Map<String,Object> params=new HashMap<>(4);
|
|
|
|
try {
|
|
try {
|
|
-
|
|
|
|
|
|
+ Map<String,Object> data=new HashMap<>(2);
|
|
|
|
+ data.put("list",null);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- logger.error("数据统计列表异常", e);
|
|
|
|
|
|
+ logger.error("作业批改痕迹异常", e);
|
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
|
+ }
|
|
|
|
+ return responseEntity;
|
|
|
|
+ }
|
|
|
|
+ @RequestMapping(value = "/salaryList", method = RequestMethod.POST)
|
|
|
|
+ @ApiOperation(value = "薪酬列表", notes = "薪酬列表")
|
|
|
|
+ public ResponseEntity salaryList(@RequestParam(name = "accessToken") String accessToken,@RequestBody TeacherDelReq req) {
|
|
|
|
+ ResponseEntity responseEntity = new ResponseEntity();
|
|
|
|
+ try {
|
|
|
|
+ Map<String,Object> data=new HashMap<>(2);
|
|
|
|
+ TbLibManager manager = managerService.getById(req.getId());
|
|
|
|
+ if(Objects.isNull(manager)){
|
|
|
|
+ return responseEntity.failure(ResponseConstant.CODE_000, "请检查传参id是否正确!");
|
|
|
|
+ }
|
|
|
|
+ List<Map<String,Object>> list = getSalaryList(manager.getUserId());
|
|
|
|
+ data.put("list",list);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("薪酬列表异常", e);
|
|
responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
}
|
|
}
|
|
return responseEntity;
|
|
return responseEntity;
|
|
}
|
|
}
|
|
|
|
+ @RequestMapping(value = "/exportSalaryList", method = RequestMethod.POST)
|
|
|
|
+ @ApiOperation(value = "导出薪酬列表", notes = "导出薪酬列表")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public void exportSalaryList(@RequestParam(name = "accessToken") String accessToken,@RequestBody TeacherDelReq req) {
|
|
|
|
+ ServletOutputStream os = null;
|
|
|
|
+ try {
|
|
|
|
+ String libName="老师薪酬统计";
|
|
|
|
+ //获得输出流
|
|
|
|
+ os = response.getOutputStream();
|
|
|
|
+ //清空输出流
|
|
|
|
+ response.reset();
|
|
|
|
+ TbLibManager manager = managerService.getById(req.getId());
|
|
|
|
+ List<Map<String,Object>> list = getSalaryList(manager.getUserId());
|
|
|
|
+ /**
|
|
|
|
+ * workDate string list 日期
|
|
|
|
+ * correctNums int list 批注总张数
|
|
|
|
+ * overtimeNums int list 超时批注总张数
|
|
|
|
+ * perkNums int list 高峰时段批注张数
|
|
|
|
+ * perkEfficiency String list 高峰时段平均批注时间
|
|
|
|
+ * errorNums int list 报错张数
|
|
|
|
+ * accuracy string list 正确率
|
|
|
|
+ * perkSalary String list 高峰时段薪资
|
|
|
|
+ * otherSalary String list 其他时段薪资
|
|
|
|
+ * salary String list 总薪资
|
|
|
|
+ */
|
|
|
|
+ StringBuilder head = new StringBuilder();
|
|
|
|
+ head.append("日期|workDate;批注总张数(张)|correctNums;超时批注总张数(张)|overtimeNums;高峰时段(18:00-20:00)批注张数(张)|perkNums;");
|
|
|
|
+ head.append("高峰时段(18:00-20:00)平均批注时间(min/张)|perkEfficiency;报错张数(张)|errorNums;正确率|accuracy;");
|
|
|
|
+ head.append("高峰时段薪资(元)|perkSalary;其他时段薪资(元)|otherSalary;总薪资(元)|salary;");
|
|
|
|
+ List<ExcelExportEntity> entity = addEntity(head.toString());
|
|
|
|
+ //把我们构造好的bean对象放到params就可以了
|
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(libName, libName, ExcelType.XSSF), entity,
|
|
|
|
+ list);
|
|
|
|
+ workbook.write(os);
|
|
|
|
+ }catch (IOException e) {
|
|
|
|
+ logger.error("异常", e);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("作业批改痕迹异常", e);
|
|
|
|
+ }finally {
|
|
|
|
+ if(os != null){
|
|
|
|
+ try {
|
|
|
|
+ os.flush();
|
|
|
|
+ os.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ logger.error("异常", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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();
|
|
|
|
+ return teacherPayService.salaryList(userId,month,year);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<ExcelExportEntity> addEntity(String exportHead){
|
|
|
|
+ List<ExcelExportEntity> entity = new ArrayList<>();
|
|
|
|
+ String[] headArr = exportHead.split(";");
|
|
|
|
+ for (String str:headArr){
|
|
|
|
+ int index = str.indexOf("|");
|
|
|
|
+ entity.add(new ExcelExportEntity(str.substring(0,index), str.substring(index+1)));
|
|
|
|
+ }
|
|
|
|
+ return entity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void exportExcelHead(HttpServletResponse response, String fileName) throws Exception{
|
|
|
|
+ String lastFileName = new String(fileName.getBytes("gb2312"), "ISO8859-1") +".xlsx";
|
|
|
|
+ //设定输出文件头
|
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename="+ lastFileName);
|
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
|
+ }
|
|
}
|
|
}
|