From 862897ae64ebf81d53ba9b10e5e80a47e55a3215 Mon Sep 17 00:00:00 2001 From: yangjun <1173114630@qq.com> Date: Wed, 2 Apr 2025 08:33:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=8F=8A=E5=90=8C=E6=AD=A5=E6=95=99=E5=B8=88=E6=89=80?= =?UTF-8?q?=E5=9C=A8=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xml/KcExportConfigTpkwcqkjzglxMapper.xml | 2 +- .../controller/KcDetectionMainController.java | 123 ++++++++++++++++-- .../kc/detection/entity/KcDetectionMain.java | 51 ++++++-- .../kc/wjxDjxx/mapper/xml/WjxDjxxMapper.xml | 4 +- .../controller/ZyInfoStudentController.java | 17 +++ .../service/IZyInfoStudentService.java | 2 + .../impl/ZyInfoStudentServiceImpl.java | 75 +++++++++++ 7 files changed, 247 insertions(+), 27 deletions(-) diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/config/mapper/xml/KcExportConfigTpkwcqkjzglxMapper.xml b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/config/mapper/xml/KcExportConfigTpkwcqkjzglxMapper.xml index 654556c3..bc223fe0 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/config/mapper/xml/KcExportConfigTpkwcqkjzglxMapper.xml +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/config/mapper/xml/KcExportConfigTpkwcqkjzglxMapper.xml @@ -214,7 +214,7 @@ - update kc_export_config_tpkwcqkjzglx t,(select gh,zzzt,mc from (select t1.gh,t1.xm,t1.zzzt,t2.mc from xxhbuser t1 left join xxhbjzgdqzt t2 on t1.ZZZT = t2.dm)a)b set t.zt = b.mc where t.gh = b.gh and t.xqxn = #{xqxn} + update kc_export_config_tpkwcqkjzglx t,(select gh,zzzt,mc,dwmc from (select t1.gh,t1.xm,t1.zzzt,t2.mc,t1.dwmc from xxhbuser t1 left join xxhbjzgdqzt t2 on t1.ZZZT = t2.dm)a)b set t.zt = b.mc , t.dwmc = b.dwmc where t.gh = b.gh and t.xqxn = #{xqxn} diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/controller/KcDetectionMainController.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/controller/KcDetectionMainController.java index fcae840a..7beb9fd8 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/controller/KcDetectionMainController.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/controller/KcDetectionMainController.java @@ -384,17 +384,118 @@ public class KcDetectionMainController extends JeecgController clazz, String title) { + // Step.1 组装查询条件 + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(kcDetectionMain, request.getParameterMap()); + 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; + } + } + if(org.apache.commons.lang.StringUtils.equals("1",adminRole)){ + QueryWrapper uqw = new QueryWrapper<>(); + uqw.eq("gh",sysUser.getUsername()); + uqw.last("limit 1"); + Xxhbuser xxhbUser = xxhbuserService.getOne(uqw); + queryWrapper.eq("ketangbiao_info ->'$.kkdw'",xxhbUser.getDwmc()); + } + + + //补充搜索 + if(StringUtils.isNotBlank(kcDetectionMain.getSearchSkrq())){ + //线上数据库不支持 + //queryWrapper.eq("JSON_VALUE(ketangbiao_info,'$.skrq')", kcDetectionMain.getSearchSkrq()); + queryWrapper.eq("ketangbiao_info ->'$.skrq'", kcDetectionMain.getSearchSkrq()); + } + if(StringUtils.isNotBlank(kcDetectionMain.getSearchHh())){ + queryWrapper.eq("ketangbiao_info -> '$.hh'", kcDetectionMain.getSearchHh()); + } + +// if(StringUtils.isNotBlank(kcDetectionMain.getSearchHh())){ +// queryWrapper.eq("ketangbiao_info -> '$.hh'", kcDetectionMain.getSearchHh()); +// } + + if(StringUtils.isNotBlank(kcDetectionMain.getSkjs())){ + queryWrapper.like("ketangbiao_info -> '$.skjs'", kcDetectionMain.getSkjs()); + } + List pageList = kcDetectionMainService.list( queryWrapper); + //补充查询子列表 + if(kcDetectionMain.getIsSelectKcDetailed() != null && kcDetectionMain.getIsSelectKcDetailed()){ + Set pidSet = Sets.newHashSet(); + Map detectionMainMap = Maps.newHashMap(); + pageList.forEach(x -> { + pidSet.add(x.getId()); + detectionMainMap.put(x.getId(),x); + x.setDetectionDetailedList(Lists.newArrayList()); + if(x.getKetangbiaoInfo() == null){ + x.setKetangbiaoInfo(new KcKetangbiao()); + } + } ); + if(!pidSet.isEmpty()){ + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().in(KcDetectionDetailed::getPid,pidSet); +// qw.orderByAsc("detection_num"); + qw.orderByAsc("create_time"); + List detailedList = kcDetectionDetailedService.list(qw); + detailedList.forEach(x -> { + if(detectionMainMap.containsKey(x.getPid())){ + KcDetectionMain pData = detectionMainMap.get(x.getPid()); + pData.getDetectionDetailedList().add(x); + } + }); + } + } + + List alist = pageList; + for(KcDetectionMain par: alist){ + par.setSkjs(par.getKetangbiaoInfo().getSkjs()); + par.setSkrq(par.getKetangbiaoInfo().getSkrq()); + par.setKkdw(par.getKetangbiaoInfo().getKkdw()); + par.setSkjc(par.getKetangbiaoInfo().getHh());; + par.setXkrs(par.getKetangbiaoInfo().getXkrs()); + Double xkrs = 0.0; + if(StringUtils.isNotBlank(par.getXkrs())){ + xkrs = Double.parseDouble(par.getXkrs()); + } + Double pjsNum = Double.parseDouble(par.getAverageNum()+""); + String cql = ""; + if(xkrs!=0 && pjsNum!=0){ + cql = String.format("%.1f",(pjsNum / xkrs) * 100) + "%"; + } + + par.setCql(cql); + + } + + + // Step.3 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + //此处设置的filename无效 ,前端会重更新设置一下 + mv.addObject(NormalExcelConstants.FILE_NAME, title); + mv.addObject(NormalExcelConstants.CLASS, clazz); + //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- + ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title); + //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- + mv.addObject(NormalExcelConstants.PARAMS,exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, pageList); + return mv; + } // // /** // * 通过excel导入数据 diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/entity/KcDetectionMain.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/entity/KcDetectionMain.java index afba5bf4..f8944154 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/entity/KcDetectionMain.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/detection/entity/KcDetectionMain.java @@ -44,12 +44,18 @@ public class KcDetectionMain implements Serializable { @DateTimeFormat(pattern="yyyy-MM-dd") @ApiModelProperty(value = "更新时间") private Date updateTime; + + + /**学年学期内部用*/ + @Excel(name = "学年学期", width = 15) + @ApiModelProperty(value = "学年学期") + private String xnxq; + + /**任务编号(课堂)*/ - @Excel(name = "任务编号(课堂)", width = 15) @ApiModelProperty(value = "任务编号(课堂)") private String rwbh; /**课程编号*/ - @Excel(name = "课程编号", width = 15) @ApiModelProperty(value = "课程编号") private String kcbh; /**课程名称*/ @@ -57,27 +63,22 @@ public class KcDetectionMain implements Serializable { @ApiModelProperty(value = "课程名称") private String kcmc; /**教室编号*/ - @Excel(name = "教室编号", width = 15) @ApiModelProperty(value = "教室编号") private String jsbh; - /**学年学期内部用*/ - @Excel(name = "学年学期内部用", width = 15) - @ApiModelProperty(value = "学年学期内部用") - private String xnxq; /**检测url*/ - @Excel(name = "检测url", width = 15) @ApiModelProperty(value = "检测url") private String detectionUrl; + /**检测次数*/ @Excel(name = "检测次数", width = 15) @ApiModelProperty(value = "检测次数") private Integer detectionNum; /**人数(累加)*/ - @Excel(name = "人数(累加)", width = 15) +// @Excel(name = "人数(累加)", width = 15) @ApiModelProperty(value = "人数(累加)") private Integer allNum; /**平均数*/ - @Excel(name = "平均数", width = 15) +// @Excel(name = "平均数", width = 15) @ApiModelProperty(value = "平均数") private Integer averageNum; /**课堂信息*/ @@ -85,6 +86,33 @@ public class KcDetectionMain implements Serializable { @ApiModelProperty(value = "课堂信息") private KcKetangbiao ketangbiaoInfo; + + + @Excel(name = "开课单位", width = 15) + @TableField(exist = false) + private String kkdw; + @Excel(name = "授课教师", width = 15) + @TableField(exist = false) + private String skjs; + + @Excel(name = "授课日期", width = 15) + @TableField(exist = false) + private String skrq; + + @Excel(name = "授课节次", width = 15) + @TableField(exist = false) + private String skjc; + + @Excel(name = "选课人数", width = 15) + @TableField(exist = false) + private String xkrs; + + @Excel(name = "出勤率", width = 15) + @TableField(exist = false) + private String cql; + + + /**详细数据子列表*/ @TableField(exist = false) private List detectionDetailedList; @@ -100,9 +128,6 @@ public class KcDetectionMain implements Serializable { /**搜索节次*/ @TableField(exist = false) private String searchHh; - /**授课教师*/ - @TableField(exist = false) - private String skjs; //迟到人数 diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/wjxDjxx/mapper/xml/WjxDjxxMapper.xml b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/wjxDjxx/mapper/xml/WjxDjxxMapper.xml index 681225fb..fa6abe13 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/wjxDjxx/mapper/xml/WjxDjxxMapper.xml +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/wjxDjxx/mapper/xml/WjxDjxxMapper.xml @@ -24,8 +24,8 @@ SELECT vid,user_id,open_time,commit_time,submit_data,jid FROM wjx_djxx a WHERE flag = '0' - and error_cn <= 3 - and create_time < date_sub(now(), INTERVAl 5 MINUTE) + and error_cn = 1 + and commit_time < date_sub(now(), INTERVAl 5 MINUTE) diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/controller/ZyInfoStudentController.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/controller/ZyInfoStudentController.java index 172e07ec..e92f5fd1 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/controller/ZyInfoStudentController.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/controller/ZyInfoStudentController.java @@ -1258,4 +1258,21 @@ public class ZyInfoStudentController extends JeecgController> getZyStuIdById(@RequestBody ZyXzryInfo zyXzryInfo) { return Result.OK(zyInfoStudentService.getZyStuIdById(zyXzryInfo)); } + + + + @GetMapping(value = "/downStudentZip") + public Result> downStudentZip(ZyInfoStudent zyInfoStudent) { + if(StringUtils.isEmpty(zyInfoStudent.getMainId())){ + return Result.error("操作失败"); + } + String downPath = zyInfoStudentService.downStudentZip(zyInfoStudent); + if(StringUtils.equals("0",downPath)){ + return Result.error("下载失败"); + } + Map map = new HashMap<>(); + map.put("status","1"); + map.put("downPath",downPath); + return Result.OK(map); + } } diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/IZyInfoStudentService.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/IZyInfoStudentService.java index b9f1f72c..723a9e8e 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/IZyInfoStudentService.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/IZyInfoStudentService.java @@ -71,4 +71,6 @@ public interface IZyInfoStudentService extends IService { List getZyStuIdById(ZyXzryInfo zyXzryInfo); void sckhclxb(); + + String downStudentZip(ZyInfoStudent zyInfoStudent); } diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java index 2f0e1dff..cc312fc9 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/zyInfoStudent/service/impl/ZyInfoStudentServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.kc.zyInfoStudent.service.impl; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -56,6 +57,8 @@ import java.net.URL; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * @Description: 学生提交作业 @@ -602,6 +605,58 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl zyInfoStudentQueryWrapper = new QueryWrapper<>(); + zyInfoStudentQueryWrapper.eq("a.main_id", zyInfoStudent.getMainId()); + zyInfoStudentQueryWrapper.isNotNull("a.file_path"); + List list = baseMapper.selectList(zyInfoStudentQueryWrapper); + if(list.size()==0){ + return "0"; + } + //六位随机数 + String title = DateUtils.formatDate(new Date(),"yyyyMMddHHmmss")+RandomUtil.randomNumbers(6); + String downTemp = "downloadZyinfoTemp"; + String downTitle = downTemp+"/学生作业附件"+title+".zip"; + String zipFileName = getUpLoadPath(downTitle); // 输出ZIP文件的名称 + + try { + File localDirFile = new File(getUpLoadPath(downTemp)); + // 判断本地目录是否存在,不存在需要新建各级目录 + if (!localDirFile.exists()) { + localDirFile.mkdirs(); + } + // 创建ZipOutputStream来写入ZIP文件 + try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFileName))) { + + for (ZyInfoStudent par : list) { + // 创建FileInputStream来读取文件 + try (FileInputStream fis = new FileInputStream(getUpLoadPath(par.getFilePath()))) { + // 创建ZipEntry,它将作为文件在ZIP归档中的条目 + ZipEntry zipEntry = new ZipEntry(par.getFilePath()); + zos.putNextEntry(zipEntry); + + // 将文件内容写入到ZipOutputStream中 + byte[] bytes = new byte[1024]; + int length; + while ((length = fis.read(bytes)) >= 0) { + zos.write(bytes, 0, length); + } + zos.closeEntry(); // 关闭当前条目,以便写入下一个文件 + }catch (Exception e){ + e.printStackTrace(); + } + } + } + System.out.println("Files have been zipped successfully."); + } catch (IOException e) { + e.printStackTrace(); + } + return downTitle; + } + + + public JSONObject getSycs(String url, String type) { Map textMap = new HashMap(); //可以设置多个input的name,value @@ -1193,6 +1248,26 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl