添加导出功能及同步教师所在单位
This commit is contained in:
parent
ee9f7b9b4c
commit
862897ae64
|
|
@ -214,7 +214,7 @@
|
|||
</select>
|
||||
|
||||
<update id="updateJzgzzzt">
|
||||
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}
|
||||
</update>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -384,17 +384,118 @@ public class KcDetectionMainController extends JeecgController<KcDetectionMain,
|
|||
// return Result.OK(kcDetectionMain);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 导出excel
|
||||
// *
|
||||
// * @param request
|
||||
// * @param kcDetectionMain
|
||||
// */
|
||||
// @RequiresPermissions("detection:kc_detection_main:exportXls")
|
||||
// @RequestMapping(value = "/exportXls")
|
||||
// public ModelAndView exportXls(HttpServletRequest request, KcDetectionMain kcDetectionMain) {
|
||||
// return super.exportXls(request, kcDetectionMain, KcDetectionMain.class, "教室人数检测-主表");
|
||||
// }
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param kcDetectionMain
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, KcDetectionMain kcDetectionMain) {
|
||||
return exportXls(request, kcDetectionMain, KcDetectionMain.class, "教室人数检测-主表");
|
||||
}
|
||||
|
||||
protected ModelAndView exportXls(HttpServletRequest request, KcDetectionMain kcDetectionMain, Class<KcDetectionMain> clazz, String title) {
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<KcDetectionMain> queryWrapper = QueryGenerator.initQueryWrapper(kcDetectionMain, request.getParameterMap());
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
List<String> 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<Xxhbuser> 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<KcDetectionMain> pageList = kcDetectionMainService.list( queryWrapper);
|
||||
//补充查询子列表
|
||||
if(kcDetectionMain.getIsSelectKcDetailed() != null && kcDetectionMain.getIsSelectKcDetailed()){
|
||||
Set<String> pidSet = Sets.newHashSet();
|
||||
Map<String, KcDetectionMain> 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<KcDetectionDetailed> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(KcDetectionDetailed::getPid,pidSet);
|
||||
// qw.orderByAsc("detection_num");
|
||||
qw.orderByAsc("create_time");
|
||||
List<KcDetectionDetailed> detailedList = kcDetectionDetailedService.list(qw);
|
||||
detailedList.forEach(x -> {
|
||||
if(detectionMainMap.containsKey(x.getPid())){
|
||||
KcDetectionMain pData = detectionMainMap.get(x.getPid());
|
||||
pData.getDetectionDetailedList().add(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
List<KcDetectionMain> 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导入数据
|
||||
|
|
|
|||
|
|
@ -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<KcDetectionDetailed> detectionDetailedList;
|
||||
|
|
@ -100,9 +128,6 @@ public class KcDetectionMain implements Serializable {
|
|||
/**搜索节次*/
|
||||
@TableField(exist = false)
|
||||
private String searchHh;
|
||||
/**授课教师*/
|
||||
@TableField(exist = false)
|
||||
private String skjs;
|
||||
|
||||
|
||||
//迟到人数
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
</select>
|
||||
|
||||
<update id="updateJid" parameterType="String">
|
||||
|
|
|
|||
|
|
@ -1258,4 +1258,21 @@ public class ZyInfoStudentController extends JeecgController<ZyInfoStudent, IZyI
|
|||
public Result<List<ZyInfoStudent>> getZyStuIdById(@RequestBody ZyXzryInfo zyXzryInfo) {
|
||||
return Result.OK(zyInfoStudentService.getZyStuIdById(zyXzryInfo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping(value = "/downStudentZip")
|
||||
public Result<Map<String,String>> 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<String,String> map = new HashMap<>();
|
||||
map.put("status","1");
|
||||
map.put("downPath",downPath);
|
||||
return Result.OK(map);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,6 @@ public interface IZyInfoStudentService extends IService<ZyInfoStudent> {
|
|||
List<ZyInfoStudent> getZyStuIdById(ZyXzryInfo zyXzryInfo);
|
||||
|
||||
void sckhclxb();
|
||||
|
||||
String downStudentZip(ZyInfoStudent zyInfoStudent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ZyInfoStudentMapper, Z
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String downStudentZip(ZyInfoStudent zyInfoStudent) {
|
||||
QueryWrapper<ZyInfoStudent> zyInfoStudentQueryWrapper = new QueryWrapper<>();
|
||||
zyInfoStudentQueryWrapper.eq("a.main_id", zyInfoStudent.getMainId());
|
||||
zyInfoStudentQueryWrapper.isNotNull("a.file_path");
|
||||
List<ZyInfoStudent> 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<String, String> textMap = new HashMap<String, String>();
|
||||
//可以设置多个input的name,value
|
||||
|
|
@ -1193,6 +1248,26 @@ public class ZyInfoStudentServiceImpl extends ServiceImpl<ZyInfoStudentMapper, Z
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件真实路径
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
private String getUpLoadPath(String path) {
|
||||
String filePath = "";
|
||||
if (org.jeecg.common.util.text.StringUtils.isEmpty(path)) {
|
||||
return "";
|
||||
}
|
||||
int idx = path.indexOf(upLoadPath);
|
||||
if (idx == -1) {
|
||||
filePath = upLoadPath + File.separator + path;
|
||||
} else {
|
||||
filePath = path;
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
//生成sign
|
||||
public static String getSign() {
|
||||
String userid = weipuId;
|
||||
|
|
|
|||
Loading…
Reference in New Issue