diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfo/controller/ZyInfoController.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfo/controller/ZyInfoController.java index 54a1b67a..9ef10877 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfo/controller/ZyInfoController.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfo/controller/ZyInfoController.java @@ -32,6 +32,7 @@ import org.jeecg.modules.kc.zyDbtx.service.IZyDbtxService; import org.jeecg.modules.kc.zyInfo.entity.CyInfoSys; import org.jeecg.modules.kc.zyInfo.entity.ZyInfo; import org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys; +import org.jeecg.modules.kc.zyInfo.pojo.ExportEntity1; import org.jeecg.modules.kc.zyInfo.service.IZyInfoService; import org.jeecg.modules.kc.zyInfoStudent.entity.ZyInfoStudent; import org.jeecg.modules.kc.zyInfoStudent.service.IZyInfoStudentService; @@ -39,6 +40,7 @@ import org.jeecg.modules.system.service.impl.SysBaseApiImpl; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; @@ -987,7 +989,104 @@ public class ZyInfoController extends JeecgController { } + @ApiOperation(value = "统计作业测试使用情况", notes = "刷新排行数据") + @GetMapping(value = "/getPHData") + public Result> getPHData(ZyInfoSys zyInfoSys, + @RequestParam(name = "tag", required = false) String tag, + HttpServletRequest req) { + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + //-------------获取当前登陆人是否是管理员角色,如果不是都按照教务秘书处理--------------------------- + List roleList = sysBaseApi.getRolesByUsername(sysUser.getUsername()); + String adminRole = "1";//0 admin 1教务秘书 + for (String role : roleList) { + if (org.apache.commons.lang.StringUtils.equals("admin", role)) { + adminRole = "0"; + break; + } + } + QueryWrapper queryWrapper = new QueryWrapper(); + if (org.apache.commons.lang.StringUtils.equals("1", adminRole)) { + QueryWrapper queryWrapperCon = new QueryWrapper(); + queryWrapperCon.eq("gh", sysUser.getUsername()); + queryWrapperCon.orderByDesc("create_time"); + queryWrapperCon.last("limit 1"); + KcExportConfigTpkwcqkjzglx kcExportConfigTpkwcqkjzglx = kcExportConfigTpkwcqkjzglxService.getOne(queryWrapperCon); + zyInfoSys.setKkdw(kcExportConfigTpkwcqkjzglx.getDwmc()); + } + if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(zyInfoSys.getXqxn())) { + KcSysConfig kcSysConfig = kcSysConfigService.getById("1"); + zyInfoSys.setXqxn(kcSysConfig.getFlag1()); + } + List list = zyInfoService.getPHData(zyInfoSys, tag); + return Result.OK(list); + } + + @ApiOperation(value = "统计作业测试使用情况", notes = "导出排行数据") + @GetMapping(value = "/exportPHData") + public ModelAndView exportPHData(ZyInfoSys zyInfoSys, @RequestParam(name = "tag", required = false) String tag) { + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + //-------------获取当前登陆人是否是管理员角色,如果不是都按照教务秘书处理--------------------------- + List roleList = sysBaseApi.getRolesByUsername(sysUser.getUsername()); + String adminRole = "1";//0 admin 1教务秘书 + for (String role : roleList) { + if (org.apache.commons.lang.StringUtils.equals("admin", role)) { + adminRole = "0"; + break; + } + } + QueryWrapper queryWrapper = new QueryWrapper(); + if (org.apache.commons.lang.StringUtils.equals("1", adminRole)) { + QueryWrapper queryWrapperCon = new QueryWrapper(); + queryWrapperCon.eq("gh", sysUser.getUsername()); + queryWrapperCon.orderByDesc("create_time"); + queryWrapperCon.last("limit 1"); + KcExportConfigTpkwcqkjzglx kcExportConfigTpkwcqkjzglx = kcExportConfigTpkwcqkjzglxService.getOne(queryWrapperCon); + zyInfoSys.setKkdw(kcExportConfigTpkwcqkjzglx.getDwmc()); + } + + if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(zyInfoSys.getXqxn())) { + KcSysConfig kcSysConfig = kcSysConfigService.getById("1"); + zyInfoSys.setXqxn(kcSysConfig.getFlag1()); + } + List list = zyInfoService.getPHData(zyInfoSys, tag); + + List exportList = list.stream() + .map(zyInfo -> { + ExportEntity1 entity = new ExportEntity1(); + // 使用 Spring 的 BeanUtils 复制属性 + BeanUtils.copyProperties(zyInfo, entity); + String rn = entity.getRownum(); + entity.setRownum(rn.substring(0,rn.indexOf("."))); + return entity; + }) + .collect(Collectors.toList()); + + String title = ""; + if ("xntop10".equals(tag)) { + title = "本学年作业使用排行"; + } + if ("jrtop10".equals(tag)) { + title = "本学年测验使用排行"; + } + if ("kctop10".equals(tag)) { + title = "本学年课程使用排行"; + } + if ("jstop10".equals(tag)) { + title = "本学年教师使用排行"; + } + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + //此处设置的filename无效 ,前端会重更新设置一下 + mv.addObject(NormalExcelConstants.FILE_NAME, title); + mv.addObject(NormalExcelConstants.CLASS, ExportEntity1.class); + //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- + ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); + exportParams.setImageBasePath(upLoadPath); + //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- + mv.addObject(NormalExcelConstants.PARAMS, exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, exportList); + return mv; + } @ApiOperation(value="统计作业使用情况", notes="统计作业使用情况") @GetMapping(value = "/sysStaticZyList")