|
@@ -1,10 +1,12 @@
|
|
|
package cn.com.qmth.examcloud.core.examwork.api.controller;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -13,8 +15,10 @@ import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
import javax.persistence.criteria.Subquery;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
@@ -37,12 +41,17 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnum;
|
|
|
import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnumManager;
|
|
|
+import cn.com.qmth.examcloud.commons.base.helpers.poi.ExcelWriter;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.DateUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.base.util.DateUtil.DatePatterns;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.JsonUtil;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.RegExpUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.web.config.SystemConfig;
|
|
|
import cn.com.qmth.examcloud.commons.web.enums.DataExecutionStatus;
|
|
|
import cn.com.qmth.examcloud.commons.web.helpers.page.PageInfo;
|
|
|
import cn.com.qmth.examcloud.commons.web.redis.RedisClient;
|
|
@@ -53,8 +62,10 @@ import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.StudentBean;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgsReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetStudentReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgsResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetStudentResp;
|
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamCourseGroupDomain;
|
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamDomain;
|
|
@@ -150,6 +161,9 @@ public class ExamController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
DataSyncCloudService dataSyncCloudService;
|
|
|
|
|
|
+ private static final String[] EXAM_ORG_SETTINGS_EXCEL_HEADER = new String[]{"学习中心ID", "学习中心代码",
|
|
|
+ "学习中心名称", "是否可以考试", "开始考试时间", "结束考试时间"};
|
|
|
+
|
|
|
@ApiOperation(value = "查询考试课程的试卷类型集合")
|
|
|
@GetMapping("queryExamCoursePaperTypeList")
|
|
|
public List<ExamPaperTypeRelationEntity> queryExamCoursePaperTypeList(
|
|
@@ -1070,6 +1084,77 @@ public class ExamController extends ControllerSupport {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "下载学习中心特殊设置", notes = "")
|
|
|
+ @GetMapping("downloadExamOrgSettings")
|
|
|
+ public void downloadTemplate(HttpServletResponse response) {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
+
|
|
|
+ Map<Long, OrgBean> orgMap = Maps.newHashMap();
|
|
|
+ GetOrgsReq getOrgsReq = new GetOrgsReq();
|
|
|
+ getOrgsReq.setRootOrgId(rootOrgId);
|
|
|
+ getOrgsReq.setEnable(true);
|
|
|
+ Long start = null;
|
|
|
+ while (true) {
|
|
|
+ getOrgsReq.setStart(start);
|
|
|
+ GetOrgsResp getOrgsResp = orgCloudService.getOrgs(getOrgsReq);
|
|
|
+ Long next = getOrgsResp.getNext();
|
|
|
+ List<OrgBean> orgBeanList = getOrgsResp.getOrgBeanList();
|
|
|
+
|
|
|
+ if (next.equals(start)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ for (OrgBean cur : orgBeanList) {
|
|
|
+ if (null == cur.getParentId()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ orgMap.put(cur.getId(), cur);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Object[]> datas = Lists.newArrayList();
|
|
|
+
|
|
|
+ List<ExamOrgSettingsEntity> orgSettingsList = examOrgSettingsRepo.findAll();
|
|
|
+ Set<Long> orgIdSet = Sets.newHashSet();
|
|
|
+ for (ExamOrgSettingsEntity cur : orgSettingsList) {
|
|
|
+ orgIdSet.add(cur.getOrgId());
|
|
|
+ OrgBean orgBean = orgMap.get(cur.getOrgId());
|
|
|
+ String examLimit = cur.getExamLimit() ? "否" : "是";
|
|
|
+ String beginTime = null == cur.getBeginTime()
|
|
|
+ ? null
|
|
|
+ : DateUtil.format(cur.getBeginTime(), DatePatterns.ISO);
|
|
|
+ String endTime = null == cur.getEndTime()
|
|
|
+ ? null
|
|
|
+ : DateUtil.format(cur.getEndTime(), DatePatterns.ISO);
|
|
|
+ datas.add(new Object[]{String.valueOf(orgBean.getId()), orgBean.getCode(),
|
|
|
+ orgBean.getName(), examLimit, beginTime, endTime});
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Entry<Long, OrgBean> entry : orgMap.entrySet()) {
|
|
|
+ Long key = entry.getKey();
|
|
|
+ if (orgIdSet.contains(key)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ OrgBean orgBean = entry.getValue();
|
|
|
+
|
|
|
+ datas.add(new Object[]{String.valueOf(orgBean.getId()), orgBean.getCode(),
|
|
|
+ orgBean.getName(), null, null, null});
|
|
|
+ }
|
|
|
+
|
|
|
+ String filePath = SystemConfig.getTempDataDir() + File.separator
|
|
|
+ + System.currentTimeMillis() + ".xlsx";
|
|
|
+ File file = new File(filePath);
|
|
|
+
|
|
|
+ ExcelWriter.write(
|
|
|
+ EXAM_ORG_SETTINGS_EXCEL_HEADER, new Class[]{String.class, String.class,
|
|
|
+ String.class, String.class, String.class, String.class},
|
|
|
+ datas, new File(filePath));
|
|
|
+
|
|
|
+ exportFile("学习中心特殊设置-" + getRootOrgId() + ".xlsx", file);
|
|
|
+
|
|
|
+ FileUtils.deleteQuietly(file);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 方法注释
|
|
|
*
|