|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
import cn.jlw.util.excel.listener.MyValidateExcelCellDataListener;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ibeetl.admin.console.service.UserConsoleService;
|
|
|
import com.ibeetl.admin.core.dao.CoreUserRoleDao;
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
import com.ibeetl.admin.core.entity.CoreUserRole;
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
import com.ibeetl.admin.core.service.CorePlatformService;
|
|
|
import com.ibeetl.admin.core.service.CoreUserService;
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
import com.ibeetl.admin.core.util.TimeTool;
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
import com.ibeetl.jlw.dao.*;
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
import com.ibeetl.jlw.entity.vo.StudentLogAnalysisVO;
|
|
|
import com.ibeetl.jlw.entity.vo.StudentLoginLogVO;
|
|
|
import com.ibeetl.jlw.entity.vo.StudentUseLogVO;
|
|
|
import com.ibeetl.jlw.job.CacheLogJob;
|
|
|
import com.ibeetl.jlw.util.HttpJsonRequest;
|
|
|
import com.ibeetl.jlw.web.query.*;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
import org.beetl.sql.core.query.LambdaQuery;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.validation.constraints.NotBlank;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.security.MessageDigest;
|
|
|
import java.sql.SQLException;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.Callable;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.Future;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
|
|
|
import static cn.jlw.token.TokenService.updateByIds;
|
|
|
import static cn.jlw.util.CacheUserUtil.getUniAdmin;
|
|
|
import static com.ibeetl.admin.core.enums.MenuEnums.JT_02;
|
|
|
import static com.ibeetl.admin.core.enums.MenuEnums.JT_S_03;
|
|
|
import static com.ibeetl.admin.core.util.ListUtils.getDuplicateElements;
|
|
|
import static com.ibeetl.jlw.web.IpAddressController.ipAddressMap;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Student Service
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
@Validated
|
|
|
@Transactional
|
|
|
public class StudentService extends CoreBaseService<Student> {
|
|
|
|
|
|
@Autowired
|
|
|
private StudentDao studentDao;
|
|
|
@Autowired
|
|
|
private SchoolClassDao schoolClassDao;
|
|
|
@Autowired
|
|
|
private CoreUserRoleDao coreUserRoleDao;
|
|
|
@Autowired
|
|
|
private StudentQuestionLogService studentQuestionLogService;
|
|
|
@Autowired
|
|
|
private StudentQuestionLogInfoService studentQuestionLogInfoService;
|
|
|
@Autowired
|
|
|
private StudentQuestionLogAnswerService studentQuestionLogAnswerService;
|
|
|
@Autowired
|
|
|
private WrongQuestionService wrongQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
CorePlatformService platformService;
|
|
|
|
|
|
@Autowired
|
|
|
UserConsoleService userConsoleService;
|
|
|
|
|
|
@Autowired
|
|
|
SchoolClassService schoolClassService;
|
|
|
|
|
|
@Autowired
|
|
|
private CompetitionService competitionService;
|
|
|
@Autowired
|
|
|
private CompetitionStudentsService competitionStudentsService;
|
|
|
@Autowired
|
|
|
private CompetitionTaskOneQuestionService competitionTaskOneQuestionService;
|
|
|
@Autowired
|
|
|
private CompetitionTaskSecondQuestionService competitionTaskSecondQuestionService;
|
|
|
@Autowired
|
|
|
private CompetitionTaskSecondQuestionStepService competitionTaskSecondQuestionStepService;
|
|
|
|
|
|
@Autowired
|
|
|
private ExamService examService;
|
|
|
@Autowired
|
|
|
private ExamStudentsService examStudentsService;
|
|
|
@Autowired
|
|
|
private ExamTaskOneQuestionService examTaskOneQuestionService;
|
|
|
@Autowired
|
|
|
private ExamTaskSecondQuestionService examTaskSecondQuestionService;
|
|
|
@Autowired
|
|
|
private ExamTaskSecondQuestionStepService examTaskSecondQuestionStepService;
|
|
|
@Autowired
|
|
|
private ExamTaskThreeQuestionService examTaskThreeQuestionService;
|
|
|
@Autowired
|
|
|
private ExamTaskThreeQuestionStepService examTaskThreeQuestionStepService;
|
|
|
|
|
|
@Autowired
|
|
|
private ResourcesQuestionService resourcesQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
private CourseInfoService courseInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
private StudentDefenceLogService studentDefenceLogService;
|
|
|
@Autowired
|
|
|
private StudentDefenceLogInfoService studentDefenceLogInfoService;
|
|
|
@Autowired
|
|
|
private StudentDefenceLogNoteService studentDefenceLogNoteService;
|
|
|
|
|
|
@Autowired
|
|
|
private StudentAccountAssetAllocationService studentAccountAssetAllocationService;
|
|
|
@Autowired
|
|
|
private CoreUserService coreUserService;
|
|
|
|
|
|
private final ExecutorService pool = Executors.newCachedThreadPool();
|
|
|
@Autowired
|
|
|
private WebPlatformService webPlatformService;
|
|
|
@Autowired
|
|
|
private UniversitiesCollegesService universitiesCollegesService;
|
|
|
|
|
|
public PageQuery<Student> queryByCondition(PageQuery query) {
|
|
|
PageQuery<Student> ret = studentDao.queryByCondition(query);
|
|
|
List<Student> list = ret.getList();
|
|
|
CollectionUtil.emptyIfNull(list).forEach(item -> {
|
|
|
item.setStudentPassword(null);
|
|
|
});
|
|
|
queryListAfter(list);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询学生日志
|
|
|
* 操作日志,Mock
|
|
|
*
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
public PageQuery<Student> queryLogByCondition(PageQuery query) {
|
|
|
PageQuery ret = studentDao.queryByCondition(query);
|
|
|
List<Student> studentList = ret.getList();
|
|
|
queryListAfter(studentList);
|
|
|
|
|
|
if (ObjectUtil.isEmpty(studentList)) {
|
|
|
return ret;
|
|
|
}
|
|
|
// 学生为主表,则学生ID为条件
|
|
|
String studentIds = studentList.stream().map(Student::getStudentId).map(Object::toString).collect(Collectors.joining(","));
|
|
|
|
|
|
Map<String, List<Student>> groupByStudentId = CacheLogJob.studentLogMap;
|
|
|
|
|
|
if (ObjectUtil.isAllNotEmpty(studentIds) && ObjectUtil.isEmpty(groupByStudentId)) {
|
|
|
StudentQuery studentQuery = new StudentQuery();
|
|
|
studentQuery.setStudentIds(studentIds);
|
|
|
List<Student> studentLogList = defaultIfNull(getStudentLog(studentQuery), Collections.emptyList());
|
|
|
groupByStudentId = studentLogList.stream().collect(Collectors.groupingBy(e -> e.get("platform") + "" + e.getStudentId()));
|
|
|
}
|
|
|
|
|
|
if (null != groupByStudentId) {
|
|
|
for (Student student : studentList) {
|
|
|
String key = student.get("platform") + "" + student.getStudentId();
|
|
|
List<Student> studentLogList = groupByStudentId.get(key);
|
|
|
if (null != studentLogList && studentLogList.size() > 0) {
|
|
|
Student studentLog = studentLogList.get(0);
|
|
|
student.set("lastLoginTime", studentLog.get("lastLoginTime"));
|
|
|
student.set("onlineDuration", TimeTool.diffTime(studentLog.get("lastLoginTime"), studentLog.get("lastOperateTime")));
|
|
|
student.set("ip", studentLog.get("ip"));
|
|
|
IpAddress ipAddress = null != studentLog.get("ip") && StringUtils.isNotBlank(studentLog.get("ip").toString()) ? ipAddressMap.get(studentLog.get("ip").toString()) : null;
|
|
|
student.set("ipAddress", null != ipAddress ? (ipAddress.getProvince() + ipAddress.getCity() + ipAddress.getDistrict()) : null);//IP地址
|
|
|
} else {
|
|
|
student.set("lastLoginTime", RandomUtil.randomDay(-20, -1));
|
|
|
student.set("onlineDuration", RandomUtil.randomNumber());
|
|
|
student.set("ip", "127.0.0.1");
|
|
|
student.set("ipAddress", "安徽");
|
|
|
}
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(studentList)) {
|
|
|
studentList = studentList.stream().sorted(Comparator.comparing(v -> (Date) v.get("lastLoginTime"))).collect(Collectors.toList());
|
|
|
Collections.reverse(studentList);
|
|
|
ret.setList(studentList);
|
|
|
}
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public PageQuery<StudentLoginLogVO> queryStudentLoginLogByCondition(PageQuery query) {
|
|
|
UniversitiesColleges uniAdmin = getUniAdmin();
|
|
|
|
|
|
if (null != uniAdmin) {
|
|
|
query.setPara("universitiesCollegesId", uniAdmin.getUniversitiesCollegesId());
|
|
|
}
|
|
|
return studentDao.queryStudentLoginLogByCondition(query);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 登录日志
|
|
|
*
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
public PageQuery<StudentLoginLogVO> queryUserLoginLogByCondition(PageQuery query) {
|
|
|
UniversitiesColleges uniAdmin = getUniAdmin();
|
|
|
|
|
|
if (null != uniAdmin) {
|
|
|
query.setPara("universitiesCollegesId", uniAdmin.getUniversitiesCollegesId());
|
|
|
}
|
|
|
return studentDao.queryUserLoginLogByCondition(query);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询学生日志
|
|
|
* 操作日志,真实数据
|
|
|
* <p>
|
|
|
* 返回值:
|
|
|
* lastLoginTime 最后登录时间
|
|
|
* onlineDuration 在线时长
|
|
|
* ip 登录IP
|
|
|
* ipAddress (IP转换成省市区)
|
|
|
* 等等
|
|
|
*
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
public PageQuery<StudentUseLogVO> queryStudentUseLogByCondition(PageQuery query) {
|
|
|
UniversitiesColleges uniAdmin = getUniAdmin();
|
|
|
|
|
|
if (null != uniAdmin) {
|
|
|
query.setPara("universitiesCollegesId", uniAdmin.getUniversitiesCollegesId());
|
|
|
}
|
|
|
// return studentDao.queryStudentUseLogByCondition(query);
|
|
|
return studentDao.queryStudentTeacherOrUseLogBy(query);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 行为日志分析
|
|
|
*
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
public PageQuery<StudentLogAnalysisVO> queryStudentLogAnalysisByCondition(PageQuery query) {
|
|
|
UniversitiesColleges uniAdmin = getUniAdmin();
|
|
|
|
|
|
if (null != uniAdmin) {
|
|
|
query.setPara("universitiesCollegesId", uniAdmin.getUniversitiesCollegesId());
|
|
|
}
|
|
|
return studentDao.queryStudentLogAnalysisByCondition(query);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 统计报表-总人数统计
|
|
|
*
|
|
|
* @param query
|
|
|
* @return
|
|
|
*/
|
|
|
public PageQuery<StudentLogAnalysisVO> queryStatisticalStatementNumberPeopleByCondition(PageQuery query) {
|
|
|
UniversitiesColleges uniAdmin = getUniAdmin();
|
|
|
|
|
|
if (null != uniAdmin) {
|
|
|
query.setPara("universitiesCollegesId", uniAdmin.getUniversitiesCollegesId());
|
|
|
}
|
|
|
return studentDao.queryStatisticalStatementNumberPeopleByCondition(query);
|
|
|
}
|
|
|
|
|
|
public PageQuery<Student> queryPracticePerformanceStatistic(PageQuery query) {
|
|
|
PageQuery ret = studentDao.getPracticePerformanceStatistic(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public List<CourseInfo> getPracticePerformanceStatisticInfoList(StudentQuery studentQuery) {
|
|
|
|
|
|
String courseInfoIds = "";
|
|
|
List<CourseInfo> courseInfoList = new ArrayList<>();
|
|
|
|
|
|
CourseInfo courseInfo = courseInfoService.getTreeById(studentQuery.getCourseInfoId());
|
|
|
List<CourseInfo> childrenList = courseInfo.takeChildren();
|
|
|
for (int i = 0; null != childrenList && i < childrenList.size(); i++) {
|
|
|
courseInfoList.add(childrenList.get(i));
|
|
|
courseInfoIds += childrenList.get(i).getCourseInfoId() + ",";
|
|
|
List<CourseInfo> childrenChildrenList = childrenList.get(i).takeChildren();
|
|
|
for (int j = 0; j < childrenChildrenList.size(); j++) {
|
|
|
courseInfoList.add(childrenChildrenList.get(j));
|
|
|
courseInfoIds += childrenChildrenList.get(j).getCourseInfoId() + ",";
|
|
|
List<CourseInfo> childrenChildrenChildrenList = childrenChildrenList.get(j).takeChildren();
|
|
|
for (int k = 0; k < childrenChildrenChildrenList.size(); k++) {
|
|
|
childrenChildrenChildrenList.get(k).setCourseInfoName(" " + childrenChildrenChildrenList.get(k).getCourseInfoName());
|
|
|
courseInfoList.add(childrenChildrenChildrenList.get(k));
|
|
|
courseInfoIds += childrenChildrenChildrenList.get(k).getCourseInfoId() + ",";
|
|
|
List<CourseInfo> childrenChildrenChildrenChildrenList = childrenChildrenChildrenList.get(k).takeChildren();
|
|
|
for (int l = 0; l < childrenChildrenChildrenChildrenList.size(); l++) {
|
|
|
childrenChildrenChildrenList.get(k).setCourseInfoName("  " + childrenChildrenChildrenList.get(k).getCourseInfoName());
|
|
|
courseInfoList.add(childrenChildrenChildrenChildrenList.get(l));
|
|
|
courseInfoIds += childrenChildrenChildrenChildrenList.get(l).getCourseInfoId() + ",";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
childrenList.get(i).putChildren(new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
Map<Long, List<Student>> groupByCourseInfoId = null;
|
|
|
|
|
|
if (StringUtils.isNotBlank(courseInfoIds)) {
|
|
|
StudentQuery query = new StudentQuery();
|
|
|
query.setCourseInfoIds(courseInfoIds);
|
|
|
query.setStudentId(studentQuery.getStudentId());
|
|
|
query.setOrgId(studentQuery.getOrgId());
|
|
|
List<Student> studentLogList = getPracticePerformanceStatisticInfo(query);
|
|
|
try {
|
|
|
groupByCourseInfoId = studentLogList.stream().collect(Collectors.groupingBy(e -> Long.parseLong(null != e.get("courseInfoId") ? e.get("courseInfoId").toString() : "-1")));
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (null != groupByCourseInfoId) {
|
|
|
for (int i = 0; i < childrenList.size(); i++) {
|
|
|
List<Student> studentLogList = groupByCourseInfoId.get(childrenList.get(i).getCourseInfoId());
|
|
|
if (null != studentLogList && studentLogList.size() > 0) {
|
|
|
Student studentLog = studentLogList.get(0);
|
|
|
childrenList.get(i).set("resourcesQuestionNum", studentLog.get("resourcesQuestionNum"));
|
|
|
childrenList.get(i).set("resourcesCompetitionNum", studentLog.get("resourcesCompetitionNum"));
|
|
|
childrenList.get(i).set("resourcesTrainingNum", studentLog.get("resourcesTrainingNum"));
|
|
|
childrenList.get(i).set("resourcesQuestionProportion", studentLog.get("resourcesQuestionProportion"));
|
|
|
childrenList.get(i).set("resourcesCompetitionProportion", studentLog.get("resourcesCompetitionProportion"));
|
|
|
childrenList.get(i).set("resourcesTrainingProportion", studentLog.get("resourcesTrainingProportion"));
|
|
|
} else {
|
|
|
childrenList.get(i).set("resourcesQuestionNum", null);
|
|
|
childrenList.get(i).set("resourcesCompetitionNum", null);
|
|
|
childrenList.get(i).set("resourcesTrainingNum", null);
|
|
|
childrenList.get(i).set("resourcesQuestionProportion", null);
|
|
|
childrenList.get(i).set("resourcesCompetitionProportion", null);
|
|
|
childrenList.get(i).set("resourcesTrainingProportion", null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return childrenList;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<CourseInfo> getPracticeProgressList(StudentQuery studentQuery) {
|
|
|
|
|
|
String courseInfoIds = "";
|
|
|
List<CourseInfo> courseInfoList = new ArrayList<>();
|
|
|
|
|
|
CourseInfo courseInfo = courseInfoService.getTreeById(studentQuery.getCourseInfoId());
|
|
|
List<CourseInfo> childrenList = courseInfo.takeChildren();
|
|
|
for (int i = 0; null != childrenList && i < childrenList.size(); i++) {
|
|
|
courseInfoList.add(childrenList.get(i));
|
|
|
courseInfoIds += childrenList.get(i).getCourseInfoId() + ",";
|
|
|
List<CourseInfo> childrenChildrenList = childrenList.get(i).takeChildren();
|
|
|
for (int j = 0; j < childrenChildrenList.size(); j++) {
|
|
|
courseInfoList.add(childrenChildrenList.get(j));
|
|
|
courseInfoIds += childrenChildrenList.get(j).getCourseInfoId() + ",";
|
|
|
List<CourseInfo> childrenChildrenChildrenList = childrenChildrenList.get(j).takeChildren();
|
|
|
for (int k = 0; k < childrenChildrenChildrenList.size(); k++) {
|
|
|
childrenChildrenChildrenList.get(k).setCourseInfoName(" " + childrenChildrenChildrenList.get(k).getCourseInfoName());
|
|
|
courseInfoList.add(childrenChildrenChildrenList.get(k));
|
|
|
courseInfoIds += childrenChildrenChildrenList.get(k).getCourseInfoId() + ",";
|
|
|
List<CourseInfo> childrenChildrenChildrenChildrenList = childrenChildrenChildrenList.get(k).takeChildren();
|
|
|
for (int l = 0; l < childrenChildrenChildrenChildrenList.size(); l++) {
|
|
|
childrenChildrenChildrenList.get(k).setCourseInfoName("  " + childrenChildrenChildrenList.get(k).getCourseInfoName());
|
|
|
courseInfoList.add(childrenChildrenChildrenChildrenList.get(l));
|
|
|
courseInfoIds += childrenChildrenChildrenChildrenList.get(l).getCourseInfoId() + ",";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
childrenList.get(i).putChildren(new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
Map<Long, List<Student>> groupByCourseInfoId = null;
|
|
|
|
|
|
if (StringUtils.isNotBlank(courseInfoIds)) {
|
|
|
StudentQuery query = new StudentQuery();
|
|
|
query.setCourseInfoIds(courseInfoIds);
|
|
|
query.setStudentId(studentQuery.getStudentId());
|
|
|
query.setClassId(studentQuery.getClassId());
|
|
|
query.setOrgId(studentQuery.getOrgId());
|
|
|
List<Student> studentLogList = getPracticeProgress(query);
|
|
|
try {
|
|
|
groupByCourseInfoId = studentLogList.stream().collect(Collectors.groupingBy(e -> Long.parseLong(null != e.get("courseInfoId") ? e.get("courseInfoId").toString() : "-1")));
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (null != groupByCourseInfoId) {
|
|
|
for (int i = 0; i < childrenList.size(); i++) {
|
|
|
List<Student> studentLogList = groupByCourseInfoId.get(childrenList.get(i).getCourseInfoId());
|
|
|
if (null != studentLogList && studentLogList.size() > 0) {
|
|
|
Student studentLog = studentLogList.get(0);
|
|
|
childrenList.get(i).set("resourcesQuestionNum", studentLog.get("resourcesQuestionNum"));
|
|
|
childrenList.get(i).set("resourcesCompetitionNum", studentLog.get("resourcesCompetitionNum"));
|
|
|
childrenList.get(i).set("resourcesTrainingNum", studentLog.get("resourcesTrainingNum"));
|
|
|
childrenList.get(i).set("resourcesQuestionProportion", studentLog.get("resourcesQuestionProportion"));
|
|
|
childrenList.get(i).set("resourcesCompetitionProportion", studentLog.get("resourcesCompetitionProportion"));
|
|
|
childrenList.get(i).set("resourcesTrainingProportion", studentLog.get("resourcesTrainingProportion"));
|
|
|
} else {
|
|
|
childrenList.get(i).set("resourcesQuestionNum", null);
|
|
|
childrenList.get(i).set("resourcesCompetitionNum", null);
|
|
|
childrenList.get(i).set("resourcesTrainingNum", null);
|
|
|
childrenList.get(i).set("resourcesQuestionProportion", null);
|
|
|
childrenList.get(i).set("resourcesCompetitionProportion", null);
|
|
|
childrenList.get(i).set("resourcesTrainingProportion", null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return childrenList;
|
|
|
}
|
|
|
|
|
|
|
|
|
public PageQuery<Student> queryByCondition2Student(PageQuery query) {
|
|
|
PageQuery ret = studentDao.queryByCondition2Student(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public List<Student> getStudentLog(StudentQuery studentQuery) {
|
|
|
return studentDao.getStudentLog(studentQuery);
|
|
|
}
|
|
|
|
|
|
public List<Student> getPracticePerformanceStatisticInfo(StudentQuery studentQuery) {
|
|
|
return studentDao.getPracticePerformanceStatisticInfo(studentQuery);
|
|
|
}
|
|
|
|
|
|
public List<Student> getPracticeProgress(StudentQuery studentQuery) {
|
|
|
return studentDao.getPracticeProgress(studentQuery);
|
|
|
}
|
|
|
|
|
|
public PageQuery<CourseInfo> getErrorStatistics(PageQuery query) {
|
|
|
PageQuery ret = studentDao.getErrorStatistics(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public void deleteStudent(String ids) {
|
|
|
|
|
|
String userIds = "";
|
|
|
List<Student> studentList = studentDao.getByIds(ids);
|
|
|
for (int i = 0; i < studentList.size(); i++) {
|
|
|
userIds += studentList.get(i).getUserId() + ",";
|
|
|
}
|
|
|
|
|
|
//置空相应coreUser的code
|
|
|
userConsoleService.batchSetCodeNullByIds(userIds);
|
|
|
// 批量置空 学生编号后面追加@_DEL, 代表已经删除了
|
|
|
studentDao.batchAppendCodeDelByIds(ids);
|
|
|
// 逻辑删除学生
|
|
|
studentDao.deleteStudentByIds(ids);
|
|
|
}
|
|
|
|
|
|
public void deleteByList(List list) {
|
|
|
String ids = "";
|
|
|
for (int i = 0; null != list && i < list.size(); i++) {
|
|
|
ids += list.get(i).toString() + ",";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(ids)) {
|
|
|
studentDao.deleteByIds(ids);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static String encryptToMD5(String input) {
|
|
|
try {
|
|
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
byte[] messageDigest = md.digest(input.getBytes());
|
|
|
|
|
|
StringBuilder hexString = new StringBuilder();
|
|
|
for (byte b : messageDigest) {
|
|
|
String hex = Integer.toHexString(0xff & b);
|
|
|
if (hex.length() == 1) {
|
|
|
hexString.append('0');
|
|
|
}
|
|
|
hexString.append(hex).append('-');
|
|
|
}
|
|
|
hexString.deleteCharAt(hexString.length() - 1); // 移除末尾多余的连字符
|
|
|
return hexString.toString().toUpperCase(); // 转换为大写形式
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public Student getStudentByStudentNoAndOrgId(String studentNo, Long orgId) {
|
|
|
List<Student> students = studentDao.getStudentByStudentNoAndOrgId(studentNo, orgId);
|
|
|
if (students != null && students.size() > 0) {
|
|
|
return students.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public Student getStudentByStudentNo(String studentNo) {
|
|
|
return studentDao.getStudentByStudentNo(studentNo);
|
|
|
}
|
|
|
|
|
|
|
|
|
public JsonResult add(@NotNull Student student) {
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
student.setStudentPassword(StringUtils.isNotBlank(student.getStudentPassword()) ? student.getStudentPassword() : "123qwe");
|
|
|
student.setAddTime(date);
|
|
|
student.setStudentStatus(1);
|
|
|
student.setCodeFrom(defaultIfNull(student.getCodeFrom(), "注册"));
|
|
|
this.save(student);
|
|
|
String code = student.createCode();
|
|
|
|
|
|
platformService.isAllowUserCodeThrowMessage(code);
|
|
|
|
|
|
SchoolClass schoolClass = schoolClassService.queryById(student.getClassId());
|
|
|
Long orgId = schoolClass.getOrgId();
|
|
|
|
|
|
// 创建系统用户并根据身份添加角色
|
|
|
Long createdUserId = webPlatformService.createUserWithRole(student.getStudentSn(), student.getStudentPassword(), orgId, JT_02, JT_S_03);
|
|
|
Student s = new Student();
|
|
|
s.setStudentId(student.getStudentId());
|
|
|
s.setUserId(createdUserId);
|
|
|
s.setOrgId(orgId);
|
|
|
s.setOldId(student.getStudentId()+80000);
|
|
|
CoreUser user = coreUserService.getUserById(createdUserId);
|
|
|
try {
|
|
|
//新建学生用户资金总表
|
|
|
studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(), orgId);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
this.updateTemplate(s);
|
|
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getById(schoolClass.getUniversitiesCollegesId());
|
|
|
Integer icibtSchoolId = universitiesColleges.getIcibtSchoolId();
|
|
|
Integer icibtClassId = schoolClass.getIcibtClassId();
|
|
|
if(icibtSchoolId!=null&&icibtClassId!=null){
|
|
|
createBxStudent(icibtSchoolId, icibtClassId, user.getCode(), student.getStudentName(), 1);
|
|
|
}
|
|
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
jsonResult.setData(student.getStudentId());
|
|
|
jsonResult.setMsg("添加成功");
|
|
|
|
|
|
//更新缓存
|
|
|
updateByIds(student.getId().toString());
|
|
|
|
|
|
return jsonResult;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JsonResult add(@NotNull Student student,Long oldUserId) {
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
student.setStudentPassword(StringUtils.isNotBlank(student.getStudentPassword()) ? student.getStudentPassword() : "123qwe");
|
|
|
student.setAddTime(date);
|
|
|
student.setStudentStatus(1);
|
|
|
student.setCodeFrom(defaultIfNull(student.getCodeFrom(), "注册"));
|
|
|
this.save(student);
|
|
|
String code = student.createCode();
|
|
|
|
|
|
platformService.isAllowUserCodeThrowMessage(code);
|
|
|
|
|
|
SchoolClass schoolClass = schoolClassService.queryById(student.getClassId());
|
|
|
Long orgId = schoolClass.getOrgId();
|
|
|
|
|
|
// 创建系统用户并根据身份添加角色
|
|
|
Long createdUserId = webPlatformService.createUserWithRole(student.getStudentSn(), student.getStudentPassword(), orgId, JT_02, JT_S_03,oldUserId);
|
|
|
Student s = new Student();
|
|
|
s.setStudentId(student.getStudentId());
|
|
|
s.setUserId(createdUserId);
|
|
|
s.setOrgId(orgId);
|
|
|
if(student.getOldId()==null){
|
|
|
s.setOldId(student.getStudentId()+80000);
|
|
|
}
|
|
|
CoreUser user = coreUserService.getUserById(createdUserId);
|
|
|
try {
|
|
|
//新建学生用户资金总表
|
|
|
// studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(), orgId);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
this.updateTemplate(s);
|
|
|
|
|
|
UniversitiesColleges universitiesColleges = universitiesCollegesService.getById(schoolClass.getUniversitiesCollegesId());
|
|
|
Integer icibtSchoolId = universitiesColleges.getIcibtSchoolId();
|
|
|
Integer icibtClassId = schoolClass.getIcibtClassId();
|
|
|
if(icibtSchoolId!=null&&icibtClassId!=null){
|
|
|
createBxStudent(icibtSchoolId, icibtClassId, user.getCode(), student.getStudentName(), 1);
|
|
|
}
|
|
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
jsonResult.setData(student.getStudentId());
|
|
|
jsonResult.setMsg("添加成功");
|
|
|
|
|
|
//更新缓存
|
|
|
updateByIds(student.getId().toString());
|
|
|
|
|
|
return jsonResult;
|
|
|
}
|
|
|
|
|
|
public void createBxStudent(Integer icibtSchoolId, Integer icibtClassId, String studentNo, String name, Integer sex) {
|
|
|
String PostData = "{'LoginName':'" + studentNo + "','Password':'" +
|
|
|
encryptToMD5("123qwe") + "','Name':'" + name + "','Sex':'" +
|
|
|
sex + "','SchoolNumber':'" + studentNo + "','RoleId':'" + 4 + "','SchoolId':'" +
|
|
|
icibtSchoolId + "','SchoolClassId':[" + icibtClassId + "]}";
|
|
|
String request = HttpJsonRequest.sendPostRequest("http://120.79.161.177:8183/SignIn/AddUser", null, PostData, "application/json");
|
|
|
}
|
|
|
|
|
|
public Boolean edit(Student student) {
|
|
|
SchoolClass schoolClass = schoolClassService.queryById(student.getClassId());
|
|
|
student.setOrgId(schoolClass.getOrgId());
|
|
|
this.updateTemplate(student);
|
|
|
student = this.queryById(student.getStudentId());
|
|
|
String code = student.createCode();//TODO 可改规则
|
|
|
|
|
|
if (!platformService.isAllowUserCode(student.getUserId(), code)) {
|
|
|
throw new PlatformException("不允许的注册账号 " + code);
|
|
|
}
|
|
|
CoreUser coreUser = new CoreUser();
|
|
|
coreUser.setId(student.getUserId());
|
|
|
coreUser.setCode(code);
|
|
|
|
|
|
userConsoleService.updateTemplate(coreUser);
|
|
|
|
|
|
//更新缓存
|
|
|
updateByIds(student.getId().toString());
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Boolean initPassword(Student student) {
|
|
|
Student s = this.queryById(student.getStudentId());
|
|
|
|
|
|
CoreUser coreUser = new CoreUser();
|
|
|
coreUser.setId(s.getUserId());
|
|
|
coreUser.setPassword("123qwe");
|
|
|
userConsoleService.updateTemplate(coreUser);
|
|
|
platformService.clearFunctionCache();
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public JsonResult importTemplate(FileEntity fileEntity, List<Long> delList, List<String> list) {
|
|
|
if (null != fileEntity) {
|
|
|
File file = new File(fileEntity.getAbsoluteUrl());
|
|
|
if (file.exists() && file.isFile() && file.canRead() && ToolUtils.findInSet("xls,xlsx", fileEntity.getFormat())) {
|
|
|
|
|
|
Workbook wb = null;
|
|
|
InputStream is = null;
|
|
|
try {
|
|
|
is = new FileInputStream(fileEntity.getAbsoluteUrl());
|
|
|
if ("xls".equals(fileEntity.getFormat())) {
|
|
|
wb = new HSSFWorkbook(is);
|
|
|
} else if ("xlsx".equals(fileEntity.getFormat())) {
|
|
|
wb = new XSSFWorkbook(is);
|
|
|
}
|
|
|
} catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
try {
|
|
|
if (null != is) {
|
|
|
is.close();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
if (wb != null) {
|
|
|
List<String[]> errMsg = new ArrayList<>();
|
|
|
String msg = "";
|
|
|
|
|
|
//获取Sheet1
|
|
|
Sheet sheet = wb.getSheet("Sheet1");
|
|
|
//获取最大行数
|
|
|
int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
//获取第一行
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
//获取最大列数
|
|
|
int colNum = firstRow.getPhysicalNumberOfCells();
|
|
|
|
|
|
String[] columns = {"院校名称", "班级名称", "学生姓名", "学号", "电话", "邮箱"};
|
|
|
|
|
|
Map<String, Integer> map = new HashMap<>();//获取需要的表头的列
|
|
|
|
|
|
//从第一列找到需要的表头
|
|
|
for (int i = 0; i < colNum; i++) {
|
|
|
String cellData = getCellFormatValue(firstRow.getCell(i));
|
|
|
for (int j = 0; j < columns.length; j++) {
|
|
|
if (columns[j].equals(cellData)) {
|
|
|
map.put(columns[j], i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//验证所需要的表头是否全
|
|
|
Integer flag = 0;
|
|
|
for (int i = 0; i < columns.length; i++) {
|
|
|
if (null != map.get(columns[i])) {
|
|
|
flag++;
|
|
|
}
|
|
|
}
|
|
|
if (flag != columns.length) {
|
|
|
return JsonResult.failMessage("导入失败,表格表头应包含 \"院校名称\",\"班级名称\",\"学生姓名\",\"学号\",\"电话\",\"邮箱\"");
|
|
|
}
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
for (int i = 1; i < rowNum; i++) {
|
|
|
Row row = sheet.getRow(i);
|
|
|
if (null == row) {
|
|
|
// msg += "第"+(i+1)+"数据为空<br>";
|
|
|
errMsg.add(new String[]{"第" + (i + 1) + "数据为空"});
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
String className = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
String studentName = getCellFormatValue(row.getCell(map.get(columns[2])));
|
|
|
String studentSn = getCellFormatValue(row.getCell(map.get(columns[3])));
|
|
|
String studentMobile = getCellFormatValue(row.getCell(map.get(columns[4])));
|
|
|
String studentEmail = getCellFormatValue(row.getCell(map.get(columns[5])));
|
|
|
|
|
|
if (StringUtils.isBlank(className)) {
|
|
|
// msg += "第"+ToolUtils.numberToLetter(map.get(columns[1])+1)+"列,第"+(i+1)+"行班级名称为空<br>";
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行班级名称为空"});
|
|
|
continue;
|
|
|
} else if (StringUtils.isBlank(studentName)) {
|
|
|
// msg += "第"+ToolUtils.numberToLetter(map.get(columns[2])+1)+"列,第"+(i+1)+"行学生姓名为空<br>";
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[2]) + 1) + "列,第" + (i + 1) + "行学生姓名为空"});
|
|
|
continue;
|
|
|
} else if (StringUtils.isBlank(studentSn)) {
|
|
|
// msg += "第"+ToolUtils.numberToLetter(map.get(columns[3])+1)+"列,第"+(i+1)+"行学号为空<br>";
|
|
|
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[3]) + 1) + "列,第" + (i + 1) + "行学号为空"});
|
|
|
continue;
|
|
|
// }else if(className.split("_").length != 2){
|
|
|
//// msg += "第"+ToolUtils.numberToLetter(map.get(columns[1])+1)+"列,第"+(i+1)+"行班级ID丢失<br>";
|
|
|
// errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[1])+1)+"列,第"+(i+1)+"行班级ID丢失"});
|
|
|
// continue;
|
|
|
} else {
|
|
|
|
|
|
String schoolClassId = "";
|
|
|
// 通过名字查询院校信息,如果查询不到就告诉前台需要先去添加院校
|
|
|
String[] classSplit = className.split("_");
|
|
|
List<SchoolClass> schoolClass = schoolClassDao.createLambdaQuery()
|
|
|
.andEq(SchoolClass::getClassName, classSplit[0])
|
|
|
.andEq(SchoolClass::getClassStatus, 1)
|
|
|
.select();
|
|
|
|
|
|
Assert.notEmpty(schoolClass, "未查询到班级:{},请先添加班级信息!", className);
|
|
|
|
|
|
// 通过名字没查询到院校的时候
|
|
|
if (ObjectUtil.isEmpty(schoolClass)) {
|
|
|
// 正则取院校ID
|
|
|
schoolClassId = classSplit[1];
|
|
|
Assert.notBlank(schoolClassId, "请先添加班级信息:{}!", className);
|
|
|
}
|
|
|
|
|
|
// 这个时候院校ID一定存在
|
|
|
schoolClassId = schoolClass.get(0).getClassId().toString();
|
|
|
|
|
|
Student pojo = new Student();
|
|
|
|
|
|
pojo.setClassId(Long.parseLong(schoolClassId));
|
|
|
pojo.setStudentName(studentName);
|
|
|
pojo.setStudentSn(studentSn);
|
|
|
pojo.setStudentMobile(studentMobile);
|
|
|
pojo.setStudentEmail(studentEmail);
|
|
|
pojo.setStudentStatus(1);
|
|
|
pojo.setStudentPassword("123qwe");
|
|
|
pojo.setAddTime(date);
|
|
|
pojo.setCodeFrom("导入");
|
|
|
save(pojo);
|
|
|
|
|
|
String code = pojo.createCode();//TODO 可改规则
|
|
|
|
|
|
// 这里不需要修改,该接口 已经丢弃。
|
|
|
if (!platformService.isAllowUserCode(code)) {
|
|
|
delList.add(pojo.getStudentId());
|
|
|
// msg += "第"+(i+1)+"行不允许的注册账号 "+code+"<br>";
|
|
|
errMsg.add(new String[]{"第" + (i + 1) + "行不允许的注册账号 " + code});
|
|
|
} else {
|
|
|
|
|
|
{
|
|
|
Student s = new Student();
|
|
|
s.setClassId(Long.parseLong(schoolClassId));
|
|
|
s.setStudentName(studentName);
|
|
|
if (studentDao.template(s).size() > 1) {
|
|
|
errMsg.add(new String[]{"第" + (i + 1) + "行存在同名同姓的学生,姓名 " + studentName + " 是否删除", pojo.getStudentId().toString()});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
CoreUser coreUser = new CoreUser();
|
|
|
coreUser.setName(pojo.getStudentName());
|
|
|
coreUser.setCode(code);
|
|
|
coreUser.setJobType0("JT_02");
|
|
|
coreUser.setJobType1("JT_S_03");
|
|
|
coreUser.setState("S1");
|
|
|
coreUser.setDelFlag(0);
|
|
|
coreUser.setCreateTime(date);
|
|
|
coreUser.setOrgId(schoolClass.get(0).getOrgId());
|
|
|
coreUser.setPassword("123qwe");
|
|
|
userConsoleService.saveUser(coreUser);
|
|
|
|
|
|
CoreUserRole coreUserRole = new CoreUserRole();
|
|
|
coreUserRole.setRoleId(192L);
|
|
|
coreUserRole.setUserId(coreUser.getId());
|
|
|
coreUserRole.setOrgId(schoolClass.get(0).getOrgId());
|
|
|
coreUserRole.setCreateTime(date);
|
|
|
coreUserRoleDao.insert(coreUserRole);
|
|
|
|
|
|
Student s = new Student();
|
|
|
s.setStudentId(pojo.getStudentId());
|
|
|
s.setStudentSn(studentSn);
|
|
|
s.setUserId(coreUser.getId());
|
|
|
s.setOrgId(schoolClass.get(0).getOrgId());
|
|
|
s.setOldId(s.getStudentId()+80000);
|
|
|
this.updateTemplate(s);
|
|
|
|
|
|
if (list.size() == 0) {
|
|
|
list.add(s.getStudentId() + ",");
|
|
|
} else {
|
|
|
String str = list.get(0) + s.getStudentId() + ",";
|
|
|
list.add(str);
|
|
|
list.remove(0);
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (count > 0) {
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
jsonResult.setData(errMsg);
|
|
|
jsonResult.setMsg("导入成功,共导入" + count + "条" + (StringUtils.isNotBlank(msg) ? "<br>" + msg : ""));
|
|
|
return jsonResult;
|
|
|
} else {
|
|
|
return JsonResult.failMessage("导入失败").setData(errMsg);
|
|
|
}
|
|
|
}
|
|
|
return JsonResult.failMessage("导入失败");
|
|
|
} else {
|
|
|
return JsonResult.failMessage("上传失败");
|
|
|
}
|
|
|
} else {
|
|
|
return JsonResult.failMessage("上传失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String getCellFormatValue(Cell cell) {
|
|
|
String value = null;
|
|
|
if (cell != null) {
|
|
|
switch (cell.getCellTypeEnum()) {
|
|
|
case STRING:
|
|
|
value = cell.getRichStringCellValue().getString();
|
|
|
break;
|
|
|
case NUMERIC:
|
|
|
String dataFormatString = cell.getCellStyle().getDataFormatString();
|
|
|
if ("m/d/yy".equals(dataFormatString) || "yyyy-mm-dd".equals(dataFormatString)) {
|
|
|
DateFormat df = new SimpleDateFormat(dataFormatString);
|
|
|
value = TimeTool.getNowTime(df.format(cell.getDateCellValue()));
|
|
|
} else {
|
|
|
DecimalFormat df = new DecimalFormat("#");
|
|
|
value = df.format(cell.getNumericCellValue());
|
|
|
}
|
|
|
break;
|
|
|
case BOOLEAN:
|
|
|
value = String.valueOf(cell.getBooleanCellValue());
|
|
|
break;
|
|
|
case FORMULA:
|
|
|
value = cell.getCellFormula();
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getExcelValues2Competition(StudentQuery studentQuery) {
|
|
|
return studentDao.getExcelValues2Competition(studentQuery);
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getExcelValues(StudentQuery studentQuery) {
|
|
|
return studentDao.getExcelValues(studentQuery);
|
|
|
}
|
|
|
|
|
|
public Student getByUserId(Long userId) {
|
|
|
return studentDao.getByUserId(userId);
|
|
|
}
|
|
|
|
|
|
public Student getByAccount(String account) {
|
|
|
return studentDao.getByAccount(account);
|
|
|
}
|
|
|
|
|
|
public List<Student> getByIds(String studentIds) {
|
|
|
return studentDao.getByIds(studentIds);
|
|
|
}
|
|
|
|
|
|
public List<Student> getValues(Object paras) {
|
|
|
return sqlManager.select(SqlId.of("jlw.student.getStudentValues"), Student.class, paras);
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<Student> getValuesByOrgId(Long orgId) {
|
|
|
return studentDao.getValuesByOrgId(orgId);
|
|
|
}
|
|
|
|
|
|
public List<Student> getValuesByQuery(StudentQuery studentQuery) {
|
|
|
List<Student> valuesByQuery = studentDao.getValuesByQuery(studentQuery);
|
|
|
queryListAfter(valuesByQuery);
|
|
|
return valuesByQuery;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取学生的关系信息
|
|
|
* 班级-专业-院系-院校
|
|
|
*
|
|
|
* @param studentIds 学生ID集合
|
|
|
* @return
|
|
|
*/
|
|
|
public StudentExtendSchoolInfo getStudentExtendSchoolInfo(@NotBlank(message = "学生ID集合不能为空!") String studentIds) {
|
|
|
List<StudentExtendSchoolInfo> infoList = studentDao.getStudentExtendSchoolInfo(studentIds);
|
|
|
return ObjectUtil.isNotEmpty(infoList) ? infoList.get(0) : null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取学生的关系信息
|
|
|
* 班级-专业-院系-院校
|
|
|
*
|
|
|
* @param studentIds 学生ID集合
|
|
|
* @return
|
|
|
*/
|
|
|
public List<StudentExtendSchoolInfo> getStudentExtendSchoolInfoList(@NotBlank(message = "学生ID集合不能为空!") String studentIds) {
|
|
|
return studentDao.getStudentExtendSchoolInfo(studentIds);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过用户ID获取学生的关系信息
|
|
|
* 班级-专业-院系-院校
|
|
|
*
|
|
|
* @param userIds 用户ID集合
|
|
|
* @return
|
|
|
*/
|
|
|
public List<StudentExtendSchoolInfo> getStudentExtendSchoolInfoListByUserIds(@NotBlank(message = "用户ID集合不能为空!") String userIds) {
|
|
|
return studentDao.getStudentExtendSchoolInfoListByUserIds(userIds);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过用户ID获取学生的关系信息
|
|
|
* 班级-专业-院系-院校
|
|
|
*
|
|
|
* @param userIds 用户ID集合
|
|
|
* @return
|
|
|
*/
|
|
|
public StudentExtendSchoolInfo getStudentExtendSchoolInfoByUserIds(@NotBlank(message = "用户ID集合不能为空!") String userIds) {
|
|
|
List<StudentExtendSchoolInfo> infoList = studentDao.getStudentExtendSchoolInfoListByUserIds(userIds);
|
|
|
return ObjectUtil.isNotEmpty(infoList) ? infoList.get(0) : null;
|
|
|
}
|
|
|
|
|
|
//大赛任务一答卷
|
|
|
public JsonResult updateCT1QuestionAnswer(CompetitionTaskOneQuestionQuery condition, Student student) {
|
|
|
if (null == condition.getCompetitionId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
if (null == student) {
|
|
|
return JsonResult.failMessage("请登录后再操作");
|
|
|
}
|
|
|
Competition competition = competitionService.getById(condition.getCompetitionId());
|
|
|
|
|
|
CompetitionStudents cs = new CompetitionStudents();
|
|
|
cs.setCompetitionId(competition.getCompetitionId());
|
|
|
cs.setStudentsId(student.getStudentId());
|
|
|
cs = competitionStudentsService.getValues(cs).get(0);
|
|
|
|
|
|
//对于交卷 加1分钟做缓冲
|
|
|
if (((Integer) 1).equals(condition.getBeSubmitted()) && null != competition && competition.getCompetitionTaskOneEndTime().getTime() < System.currentTimeMillis() - 60000) {
|
|
|
return JsonResult.failMessage("提交失败,大赛任务一已结束");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != cs && cs.getCompetitionTaskOneFinishTime() != null && cs.getCompetitionTaskOneFinishTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,已交卷");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != competition && competition.getCompetitionTaskOneEndTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,大赛任务一已结束");
|
|
|
}
|
|
|
|
|
|
CompetitionTaskOneQuestionQuery ct1QQuery = new CompetitionTaskOneQuestionQuery();
|
|
|
ct1QQuery.setCompetitionId(condition.getCompetitionId());
|
|
|
ct1QQuery.setStudentsId(student.getStudentId());
|
|
|
List<CompetitionTaskOneQuestion> oldCT1QuestionList = competitionTaskOneQuestionService.getValuesByQuery(ct1QQuery);
|
|
|
Map<Long, List<CompetitionTaskOneQuestion>> groupByCT1QId = null;
|
|
|
try {
|
|
|
groupByCT1QId = oldCT1QuestionList.stream().collect(Collectors.groupingBy(e -> e.getCompetitionTaskOneQuestionId()));
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
if (null == groupByCT1QId) {
|
|
|
return JsonResult.failMessage("数据有误,请联系管理员");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(condition.getCT1QuestionMapJson())) {
|
|
|
Map<String, JSONObject> cT1QuestionMap = new HashMap<>();
|
|
|
try {
|
|
|
cT1QuestionMap = (JSONObject.parseObject(condition.getCT1QuestionMapJson(), HashMap.class));
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
List<CompetitionTaskOneQuestion> competitionTaskOneQuestionList = new ArrayList<>();
|
|
|
|
|
|
for (Map.Entry<String, JSONObject> entry : cT1QuestionMap.entrySet()) {
|
|
|
CompetitionTaskOneQuestionQuery ct1qq = JSONObject.toJavaObject(entry.getValue(), CompetitionTaskOneQuestionQuery.class);
|
|
|
if (null != ct1qq && StringUtils.isNotBlank(ct1qq.getStudentAnswer()) && StringUtils.isNotBlank(ct1qq.getAddTime())) {
|
|
|
if (TimeTool.getTime(ct1qq.getAddTime()).getTime() <= competition.getCompetitionTaskOneEndTime().getTime()) {
|
|
|
CompetitionTaskOneQuestion competitionTaskOneQuestion = new CompetitionTaskOneQuestion();
|
|
|
if (null == groupByCT1QId.get(Long.parseLong(entry.getKey()))) {//判断答案和提交学员是否统一
|
|
|
continue;
|
|
|
}
|
|
|
competitionTaskOneQuestion.setCompetitionTaskOneQuestionId(ct1qq.getCompetitionTaskOneQuestionId());
|
|
|
competitionTaskOneQuestion.setStudentAnswer(resourcesQuestionService.answerFormat(groupByCT1QId.get(Long.parseLong(entry.getKey())).get(0).getQuestionType(), ct1qq.getStudentAnswer()));
|
|
|
competitionTaskOneQuestionList.add(competitionTaskOneQuestion);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (competitionTaskOneQuestionList.size() > 0) {
|
|
|
competitionTaskOneQuestionService.updateBatchTemplate(competitionTaskOneQuestionList);
|
|
|
}
|
|
|
} else {
|
|
|
if (null != condition.getCompetitionTaskOneQuestionId() && StringUtils.isNotBlank(condition.getStudentAnswer()) && StringUtils.isNotBlank(condition.getAddTime())) {
|
|
|
if (TimeTool.getTime(condition.getAddTime()).getTime() <= competition.getCompetitionTaskOneEndTime().getTime()) {
|
|
|
CompetitionTaskOneQuestion competitionTaskOneQuestion = new CompetitionTaskOneQuestion();
|
|
|
if (null != groupByCT1QId.get(condition.getCompetitionTaskOneQuestionId())) {//判断答案和提交学员是否统一
|
|
|
competitionTaskOneQuestion.setCompetitionTaskOneQuestionId(condition.getCompetitionTaskOneQuestionId());
|
|
|
competitionTaskOneQuestion.setStudentAnswer(condition.getStudentAnswer());
|
|
|
competitionTaskOneQuestionService.updateTemplate(competitionTaskOneQuestion);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//更新分值
|
|
|
CompetitionTaskOneQuestionQuery competitionTaskOneQuestionQuery = new CompetitionTaskOneQuestionQuery();
|
|
|
competitionTaskOneQuestionQuery.setCompetitionId(condition.getCompetitionId());
|
|
|
competitionTaskOneQuestionQuery.setStudentsId(student.getStudentId());
|
|
|
|
|
|
BigDecimal totalScore = competitionTaskOneQuestionService.getTotalScoreByQuery(competitionTaskOneQuestionQuery);
|
|
|
|
|
|
CompetitionStudents competitionStudents = new CompetitionStudents();
|
|
|
competitionStudents.setCompetitionId(condition.getCompetitionId());
|
|
|
competitionStudents.setStudentsId(student.getStudentId());
|
|
|
competitionStudents.setCompetitionTaskOneFraction(totalScore);
|
|
|
competitionStudents.setCompetitionTaskOneFinishTime(((Integer) 1).equals(condition.getBeSubmitted()) ? new Date() : null);//判断是否是交卷
|
|
|
competitionStudentsService.updateTotalScore(competitionStudents);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
//大赛任务二答卷
|
|
|
public JsonResult updateCT2QuestionAnswer(CompetitionTaskSecondQuestionStepQuery condition, Student student) {
|
|
|
if (null == condition.getCompetitionTaskSecondQuestionStepId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
if (null == student) {
|
|
|
return JsonResult.failMessage("请登录后再操作");
|
|
|
}
|
|
|
|
|
|
CompetitionTaskSecondQuestionStep competitionTaskSecondQuestionStep = competitionTaskSecondQuestionStepService.queryById(condition.getCompetitionTaskSecondQuestionStepId());
|
|
|
CompetitionTaskSecondQuestion competitionTaskSecondQuestion = competitionTaskSecondQuestionService.queryById(competitionTaskSecondQuestionStep.getCompetitionTaskSecondQuestionId());
|
|
|
CompetitionStudents competitionStudents = competitionStudentsService.queryById(competitionTaskSecondQuestion.getCompetitionStudentsId());
|
|
|
Long competitionId = competitionStudents.getCompetitionId();
|
|
|
Competition competition = competitionService.getById(competitionId);
|
|
|
condition.setAddTime(TimeTool.getNowTime());
|
|
|
|
|
|
//对于交卷 加1分钟做缓冲
|
|
|
if (((Integer) 1).equals(condition.getBeSubmitted()) && null != competition && competition.getCompetitionTaskSecondEndTime().getTime() < System.currentTimeMillis() - 60000) {
|
|
|
return JsonResult.failMessage("提交失败,大赛任务二已结束");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != competitionStudents && competitionStudents.getCompetitionTaskSecondFinishTime() != null && competitionStudents.getCompetitionTaskSecondFinishTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,已交卷");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != competition && competition.getCompetitionTaskSecondEndTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,大赛任务二已结束");
|
|
|
}
|
|
|
|
|
|
List<Future<Boolean>> results = new ArrayList<>();
|
|
|
results.add(pool.submit(new TaskCallableForCT2Q(condition, student, competition, competitionTaskSecondQuestion, competitionTaskSecondQuestionStep)));
|
|
|
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseMergeTeacher> queryByConditionQuery(PageQuery query) {
|
|
|
|
|
|
PageQuery ret = studentDao.queryByConditionQuery(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public List<Student> getStudentByStimeAndEtime(Date stime, Date etime, Long universitiesCollegesId) {
|
|
|
LambdaQuery<Student> lambdaQuery = studentDao.createLambdaQuery();
|
|
|
lambdaQuery.andEq(Student::getStudentStatus, 1);
|
|
|
if (stime != null && etime != null) {
|
|
|
lambdaQuery.andBetween(Student::getAddTime, stime, etime);
|
|
|
}
|
|
|
|
|
|
if (universitiesCollegesId != null && universitiesCollegesId != 1) {
|
|
|
// SchoolClassQuery schoolClassQuery = new SchoolClassQuery();
|
|
|
// schoolClassQuery.setUniversitiesCollegesId(universitiesCollegesId);
|
|
|
// schoolClassQuery.setClassStatus(1);
|
|
|
// List<SchoolClass> classList = schoolClassDao.getValuesByQuery(schoolClassQuery);
|
|
|
// List<Long> classIds = classList.stream().map(SchoolClass::getClassId).collect(Collectors.toList());
|
|
|
//
|
|
|
// // 如果院校没有班级,则肯定没有学生
|
|
|
// if (classIds == null || classIds.isEmpty()) {
|
|
|
// return Collections.emptyList();
|
|
|
// }
|
|
|
|
|
|
// lambdaQuery.andIn(Student::getClassId, classIds);
|
|
|
lambdaQuery.andEq(Student::getOrgId, universitiesCollegesId);
|
|
|
}
|
|
|
List<Student> select = lambdaQuery.andEq(Student::getStudentStatus, 1).select();
|
|
|
Set<Long> collect = select.stream().map(Student::getClassId).collect(Collectors.toSet());
|
|
|
List<SchoolClass> select1 = new ArrayList<SchoolClass>();
|
|
|
if (collect.size() > 0) {
|
|
|
select1 = schoolClassDao.createLambdaQuery().andIn(SchoolClass::getClassId, collect).select();
|
|
|
}
|
|
|
Set<Long> collect1 = select1.stream().map(SchoolClass::getClassId).collect(Collectors.toSet());
|
|
|
select.removeIf(next -> !collect1.contains(next.getClassId()));
|
|
|
return select;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void validateStudentSnListIsExistsThrow(List<Student> list, MyValidateExcelCellDataListener listener) {
|
|
|
if (CollectionUtil.isEmpty(list)) {
|
|
|
return;
|
|
|
}
|
|
|
// 查询所有的班级编号
|
|
|
List<String> studentSnList = list.stream().map(Student::getStudentSn).collect(Collectors.toList());
|
|
|
// 获取重复的元素
|
|
|
List<String> duplicateElements = getDuplicateElements(studentSnList);
|
|
|
|
|
|
for (String duplicateElement : duplicateElements) {
|
|
|
int errorRowIndex = studentSnList.indexOf(duplicateElement);
|
|
|
|
|
|
// 这里固定列索引,省事
|
|
|
listener.putFailMessage(
|
|
|
errorRowIndex, 2, StrUtil.format("本次上传的文件中,存在重复的的学生编号:\"{}\"!", duplicateElement));
|
|
|
}
|
|
|
|
|
|
// 查询库里已经存在的编号
|
|
|
List<String> existsList = studentDao.createLambdaQuery()
|
|
|
.andIsNotNull(Student::getStudentSn)
|
|
|
.andIn(Student::getStudentSn, studentSnList).select(String.class, "student_sn");
|
|
|
|
|
|
for (String duplicateElement : existsList) {
|
|
|
int errorRowIndex = studentSnList.indexOf(duplicateElement);
|
|
|
|
|
|
// 这里固定列索引,省事
|
|
|
listener.putFailMessage(
|
|
|
errorRowIndex, 4, StrUtil.format("已存在的学生编号:\"{}\"!", duplicateElement));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//大赛任务二答卷 线程处理
|
|
|
private class TaskCallableForCT2Q implements Callable<Boolean> {
|
|
|
CompetitionTaskSecondQuestionStepQuery condition;
|
|
|
Student student;
|
|
|
Competition competition;
|
|
|
CompetitionTaskSecondQuestion competitionTaskSecondQuestion;
|
|
|
CompetitionTaskSecondQuestionStep competitionTaskSecondQuestionStep;
|
|
|
|
|
|
public TaskCallableForCT2Q(CompetitionTaskSecondQuestionStepQuery condition, Student student, Competition competition, CompetitionTaskSecondQuestion competitionTaskSecondQuestion, CompetitionTaskSecondQuestionStep competitionTaskSecondQuestionStep) {
|
|
|
this.condition = condition;
|
|
|
this.student = student;
|
|
|
this.competition = competition;
|
|
|
this.competitionTaskSecondQuestion = competitionTaskSecondQuestion;
|
|
|
this.competitionTaskSecondQuestionStep = competitionTaskSecondQuestionStep;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean call() {
|
|
|
CompetitionStudents competitionStudents = new CompetitionStudents();
|
|
|
competitionStudents.setCompetitionId(competition.getCompetitionId());
|
|
|
competitionStudents.setStudentsId(student.getStudentId());
|
|
|
competitionStudents.setCompetitionStudentsId(competitionTaskSecondQuestion.getCompetitionStudentsId());
|
|
|
List<CompetitionStudents> competitionStudentsList = competitionStudentsService.getValues(competitionStudents);
|
|
|
|
|
|
if (null != competitionStudentsList && competitionStudentsList.size() > 0) {//判断答案和提交学员是否统一
|
|
|
if (TimeTool.getTime(condition.getAddTime()).getTime() <= competition.getCompetitionTaskSecondEndTime().getTime()) {
|
|
|
|
|
|
BigDecimal score = BigDecimal.ZERO;
|
|
|
String competitionTaskSecondQuestionStepAnswer = competitionTaskSecondQuestionStep.getCompetitionTaskSecondQuestionStepAnswer();
|
|
|
|
|
|
List<String> studentAnswerList = new ArrayList<>();
|
|
|
try {
|
|
|
studentAnswerList = JSON.parseArray(condition.getStudentAnswer(), String.class);
|
|
|
} catch (Exception e) {
|
|
|
try {
|
|
|
studentAnswerList.add(JSONObject.parseObject(condition.getStudentAnswer(), String.class));
|
|
|
} catch (Exception e1) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//将学生答案替换到题目中
|
|
|
String studentAnswer = competitionTaskSecondQuestionStep.getCompetitionTaskSecondQuestionStepQuestion();
|
|
|
for (int i = 0; null != studentAnswerList && i < studentAnswerList.size(); i++) {
|
|
|
String answer = StringUtils.isNotBlank(studentAnswerList.get(i)) ? studentAnswerList.get(i) : "";
|
|
|
studentAnswer = studentAnswer.replaceFirst("___", answer.trim());
|
|
|
}
|
|
|
|
|
|
Double d = ToolUtils.judge(competitionTaskSecondQuestionStepAnswer, studentAnswer);
|
|
|
if (d == 100.0) {
|
|
|
score = competitionTaskSecondQuestionStep.getCompetitionTaskSecondQuestionStepScore();
|
|
|
}
|
|
|
|
|
|
CompetitionTaskSecondQuestionStep ct2qStep = new CompetitionTaskSecondQuestionStep();
|
|
|
ct2qStep.setCompetitionTaskSecondQuestionStepId(condition.getCompetitionTaskSecondQuestionStepId());
|
|
|
ct2qStep.setStudentAnswer(condition.getStudentAnswer());
|
|
|
ct2qStep.setCompetitionTaskSecondQuestionStepGetScore(score);
|
|
|
competitionTaskSecondQuestionStepService.updateTemplate(ct2qStep);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//更新分值
|
|
|
CompetitionTaskSecondQuestionStepQuery competitionTaskSecondQuestionStepQuery = new CompetitionTaskSecondQuestionStepQuery();
|
|
|
competitionTaskSecondQuestionStepQuery.setCompetitionId(competition.getCompetitionId());
|
|
|
competitionTaskSecondQuestionStepQuery.setStudentsId(student.getStudentId());
|
|
|
|
|
|
BigDecimal totalScore = competitionTaskSecondQuestionStepService.getTotalScoreByQuery(competitionTaskSecondQuestionStepQuery);
|
|
|
|
|
|
competitionStudents = new CompetitionStudents();
|
|
|
competitionStudents.setCompetitionId(competition.getCompetitionId());
|
|
|
competitionStudents.setStudentsId(student.getStudentId());
|
|
|
competitionStudents.setCompetitionTaskSecondFraction(totalScore);
|
|
|
competitionStudents.setCompetitionTaskSecondFinishTime(((Integer) 1).equals(condition.getBeSubmitted()) ? new Date() : null);//判断是否是交卷
|
|
|
competitionStudentsService.updateTotalScore(competitionStudents);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//考试任务一答卷
|
|
|
public JsonResult updateET1QuestionAnswer(ExamTaskOneQuestionQuery condition, Student student) {
|
|
|
if (null == condition.getExamId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
if (null == student) {
|
|
|
return JsonResult.failMessage("请登录后再操作");
|
|
|
}
|
|
|
Exam exam = examService.queryById(condition.getExamId());
|
|
|
|
|
|
ExamStudents es = new ExamStudents();
|
|
|
es.setExamId(exam.getExamId());
|
|
|
es.setStudentsId(student.getStudentId());
|
|
|
es = examStudentsService.getValues(es).get(0);
|
|
|
|
|
|
//对于交卷 加1分钟做缓冲
|
|
|
if (((Integer) 1).equals(condition.getBeSubmitted()) && null != exam && exam.getExamTaskOneEndTime().getTime() < System.currentTimeMillis() - 60000) {
|
|
|
return JsonResult.failMessage("提交失败,考试任务一已结束");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != es && es.getExamTaskOneFinishTime() != null && es.getExamTaskOneFinishTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,已交卷");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != exam && exam.getExamTaskOneEndTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,考试任务一已结束");
|
|
|
}
|
|
|
|
|
|
ExamTaskOneQuestionQuery et1QQuery = new ExamTaskOneQuestionQuery();
|
|
|
et1QQuery.setExamId(condition.getExamId());
|
|
|
et1QQuery.setStudentsId(student.getStudentId());
|
|
|
List<ExamTaskOneQuestion> oldET1QuestionList = examTaskOneQuestionService.getValuesByQuery(et1QQuery);
|
|
|
Map<Long, List<ExamTaskOneQuestion>> groupByET1QId = null;
|
|
|
try {
|
|
|
groupByET1QId = oldET1QuestionList.stream().collect(Collectors.groupingBy(e -> e.getExamTaskOneQuestionId()));
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
if (null == groupByET1QId) {
|
|
|
return JsonResult.failMessage("数据有误,请联系管理员");
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(condition.getET1QuestionMapJson())) {
|
|
|
Map<String, JSONObject> eT1QuestionMap = new HashMap<>();
|
|
|
try {
|
|
|
eT1QuestionMap = (JSONObject.parseObject(condition.getET1QuestionMapJson(), HashMap.class));
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
List<ExamTaskOneQuestion> examTaskOneQuestionList = new ArrayList<>();
|
|
|
|
|
|
for (Map.Entry<String, JSONObject> entry : eT1QuestionMap.entrySet()) {
|
|
|
|
|
|
ExamTaskOneQuestionQuery et1qq = JSONObject.toJavaObject(entry.getValue(), ExamTaskOneQuestionQuery.class);
|
|
|
|
|
|
if (null != entry.getValue() && StringUtils.isNotBlank(et1qq.getStudentAnswer()) && StringUtils.isNotBlank(et1qq.getAddTime())) {
|
|
|
if (TimeTool.getTime(et1qq.getAddTime()).getTime() <= exam.getExamTaskOneEndTime().getTime()) {
|
|
|
ExamTaskOneQuestion examTaskOneQuestion = new ExamTaskOneQuestion();
|
|
|
if (null == groupByET1QId.get(Long.parseLong(entry.getKey()))) {//判断答案和提交学员是否统一
|
|
|
continue;
|
|
|
}
|
|
|
examTaskOneQuestion.setExamTaskOneQuestionId(et1qq.getExamTaskOneQuestionId());
|
|
|
examTaskOneQuestion.setStudentAnswer(resourcesQuestionService.answerFormat(groupByET1QId.get(Long.parseLong(entry.getKey())).get(0).getQuestionType(), et1qq.getStudentAnswer()));
|
|
|
examTaskOneQuestionList.add(examTaskOneQuestion);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (examTaskOneQuestionList.size() > 0) {
|
|
|
examTaskOneQuestionService.updateBatchTemplate(examTaskOneQuestionList);
|
|
|
}
|
|
|
} else {
|
|
|
if (null != condition.getExamTaskOneQuestionId() && StringUtils.isNotBlank(condition.getStudentAnswer()) && StringUtils.isNotBlank(condition.getAddTime())) {
|
|
|
if (TimeTool.getTime(condition.getAddTime()).getTime() <= exam.getExamTaskOneEndTime().getTime()) {
|
|
|
ExamTaskOneQuestion examTaskOneQuestion = new ExamTaskOneQuestion();
|
|
|
if (null != groupByET1QId.get(condition.getExamTaskOneQuestionId())) {//判断答案和提交学员是否统一
|
|
|
examTaskOneQuestion.setExamTaskOneQuestionId(condition.getExamTaskOneQuestionId());
|
|
|
examTaskOneQuestion.setStudentAnswer(condition.getStudentAnswer());
|
|
|
examTaskOneQuestionService.updateTemplate(examTaskOneQuestion);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//更新分值
|
|
|
ExamTaskOneQuestionQuery examTaskOneQuestionQuery = new ExamTaskOneQuestionQuery();
|
|
|
examTaskOneQuestionQuery.setExamId(condition.getExamId());
|
|
|
examTaskOneQuestionQuery.setStudentsId(student.getStudentId());
|
|
|
|
|
|
BigDecimal totalScore = examTaskOneQuestionService.getTotalScoreByQuery(examTaskOneQuestionQuery);
|
|
|
|
|
|
ExamStudents examStudents = new ExamStudents();
|
|
|
examStudents.setExamId(condition.getExamId());
|
|
|
examStudents.setStudentsId(student.getStudentId());
|
|
|
examStudents.setExamTaskOneFraction(totalScore);
|
|
|
examStudents.setExamTaskOneFinishTime(((Integer) 1).equals(condition.getBeSubmitted()) ? new Date() : null);//判断是否是交卷;
|
|
|
examStudentsService.updateTotalScore(examStudents);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
//考试任务二答卷
|
|
|
public JsonResult updateET2QuestionAnswer(ExamTaskSecondQuestionStepQuery condition, Student student) {
|
|
|
if (null == condition.getExamTaskSecondQuestionStepId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
if (null == student) {
|
|
|
return JsonResult.failMessage("请登录后再操作");
|
|
|
}
|
|
|
|
|
|
ExamTaskSecondQuestionStep examTaskSecondQuestionStep = examTaskSecondQuestionStepService.queryById(condition.getExamTaskSecondQuestionStepId());
|
|
|
ExamTaskSecondQuestion examTaskSecondQuestion = examTaskSecondQuestionService.queryById(examTaskSecondQuestionStep.getExamTaskSecondQuestionId());
|
|
|
ExamStudents examStudents = examStudentsService.queryById(examTaskSecondQuestion.getExamStudentsId());
|
|
|
Long examId = examStudents.getExamId();
|
|
|
Exam exam = examService.queryById(examId);
|
|
|
condition.setAddTime(TimeTool.getNowTime());
|
|
|
|
|
|
//对于交卷 加1分钟做缓冲
|
|
|
if (((Integer) 1).equals(condition.getBeSubmitted()) && null != exam && exam.getExamTaskSecondEndTime().getTime() < System.currentTimeMillis() - 60000) {
|
|
|
return JsonResult.failMessage("提交失败,考试任务二已结束");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != examStudents && examStudents.getExamTaskSecondFinishTime() != null && examStudents.getExamTaskSecondFinishTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,已交卷");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != exam && exam.getExamTaskSecondEndTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,考试任务二已结束");
|
|
|
}
|
|
|
|
|
|
List<Future<Boolean>> results = new ArrayList<>();
|
|
|
results.add(pool.submit(new TaskCallableForET2Q(condition, student, exam, examTaskSecondQuestion, examTaskSecondQuestionStep)));
|
|
|
|
|
|
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
|
|
|
//考试任务二答卷 线程处理
|
|
|
private class TaskCallableForET2Q implements Callable<Boolean> {
|
|
|
ExamTaskSecondQuestionStepQuery condition;
|
|
|
Student student;
|
|
|
Exam exam;
|
|
|
ExamTaskSecondQuestion examTaskSecondQuestion;
|
|
|
ExamTaskSecondQuestionStep examTaskSecondQuestionStep;
|
|
|
|
|
|
public TaskCallableForET2Q(ExamTaskSecondQuestionStepQuery condition, Student student, Exam exam, ExamTaskSecondQuestion examTaskSecondQuestion, ExamTaskSecondQuestionStep examTaskSecondQuestionStep) {
|
|
|
this.condition = condition;
|
|
|
this.student = student;
|
|
|
this.exam = exam;
|
|
|
this.examTaskSecondQuestion = examTaskSecondQuestion;
|
|
|
this.examTaskSecondQuestionStep = examTaskSecondQuestionStep;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean call() {
|
|
|
ExamStudents examStudents = new ExamStudents();
|
|
|
examStudents.setExamId(exam.getExamId());
|
|
|
examStudents.setStudentsId(student.getStudentId());
|
|
|
examStudents.setExamStudentsId(examTaskSecondQuestion.getExamStudentsId());
|
|
|
List<ExamStudents> examStudentsList = examStudentsService.getValues(examStudents);
|
|
|
|
|
|
if (null != examStudentsList && examStudentsList.size() > 0) {//判断答案和提交学员是否统一
|
|
|
if (TimeTool.getTime(condition.getAddTime()).getTime() <= exam.getExamTaskSecondEndTime().getTime()) {
|
|
|
|
|
|
BigDecimal score = BigDecimal.ZERO;
|
|
|
String competitionTaskSecondQuestionStepAnswer = examTaskSecondQuestionStep.getExamTaskSecondQuestionStepAnswer();
|
|
|
|
|
|
List<String> studentAnswerList = new ArrayList<>();
|
|
|
try {
|
|
|
studentAnswerList = JSON.parseArray(condition.getStudentAnswer(), String.class);
|
|
|
} catch (Exception e) {
|
|
|
try {
|
|
|
studentAnswerList.add(JSONObject.parseObject(condition.getStudentAnswer(), String.class));
|
|
|
} catch (Exception e1) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//将学生答案替换到题目中
|
|
|
String studentAnswer = examTaskSecondQuestionStep.getExamTaskSecondQuestionStepQuestion();
|
|
|
for (int i = 0; null != studentAnswerList && i < studentAnswerList.size(); i++) {
|
|
|
String answer = StringUtils.isNotBlank(studentAnswerList.get(i)) ? studentAnswerList.get(i) : "";
|
|
|
studentAnswer = studentAnswer.replaceFirst("___", answer.trim());
|
|
|
}
|
|
|
|
|
|
Double d = ToolUtils.judge(competitionTaskSecondQuestionStepAnswer, studentAnswer);
|
|
|
if (d == 100.00) {//TODO 暂定99%以上相似为正确
|
|
|
score = examTaskSecondQuestionStep.getExamTaskSecondQuestionStepScore();
|
|
|
}
|
|
|
|
|
|
ExamTaskSecondQuestionStep ct2qStep = new ExamTaskSecondQuestionStep();
|
|
|
ct2qStep.setExamTaskSecondQuestionStepId(condition.getExamTaskSecondQuestionStepId());
|
|
|
ct2qStep.setStudentAnswer(condition.getStudentAnswer());
|
|
|
ct2qStep.setExamTaskSecondQuestionStepGetScore(score);
|
|
|
examTaskSecondQuestionStepService.updateTemplate(ct2qStep);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//更新分值
|
|
|
ExamTaskSecondQuestionStepQuery examTaskSecondQuestionStepQuery = new ExamTaskSecondQuestionStepQuery();
|
|
|
examTaskSecondQuestionStepQuery.setExamId(exam.getExamId());
|
|
|
examTaskSecondQuestionStepQuery.setStudentsId(student.getStudentId());
|
|
|
|
|
|
BigDecimal totalScore = examTaskSecondQuestionStepService.getTotalScoreByQuery(examTaskSecondQuestionStepQuery);
|
|
|
|
|
|
examStudents = new ExamStudents();
|
|
|
examStudents.setExamId(exam.getExamId());
|
|
|
examStudents.setStudentsId(student.getStudentId());
|
|
|
examStudents.setExamTaskSecondFraction(totalScore);
|
|
|
examStudents.setExamTaskSecondFinishTime(((Integer) 1).equals(condition.getBeSubmitted()) ? new Date() : null);//判断是否是交卷;
|
|
|
examStudentsService.updateTotalScore(examStudents);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//考试任务三答卷
|
|
|
public JsonResult updateET3QuestionAnswer(ExamTaskThreeQuestionStepQuery condition, Student student) {
|
|
|
if (null == condition.getExamTaskThreeQuestionStepId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
if (null == student) {
|
|
|
return JsonResult.failMessage("请登录后再操作");
|
|
|
}
|
|
|
|
|
|
ExamTaskThreeQuestionStep examTaskThreeQuestionStep = examTaskThreeQuestionStepService.queryById(condition.getExamTaskThreeQuestionStepId());
|
|
|
ExamTaskThreeQuestion examTaskThreeQuestion = examTaskThreeQuestionService.queryById(examTaskThreeQuestionStep.getExamTaskThreeQuestionId());
|
|
|
ExamStudents examStudents = examStudentsService.queryById(examTaskThreeQuestion.getExamStudentsId());
|
|
|
Long examId = examStudents.getExamId();
|
|
|
Exam exam = examService.queryById(examId);
|
|
|
condition.setAddTime(TimeTool.getNowTime());
|
|
|
|
|
|
//对于交卷 加1分钟做缓冲
|
|
|
if (((Integer) 1).equals(condition.getBeSubmitted()) && null != exam && exam.getExamTaskThreeEndTime().getTime() < System.currentTimeMillis() - 60000) {
|
|
|
return JsonResult.failMessage("提交失败,考试任务三已结束");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != examStudents && examStudents.getExamTaskThreeFinishTime() != null && examStudents.getExamTaskThreeFinishTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,已交卷");
|
|
|
} else if (!((Integer) 1).equals(condition.getBeSubmitted()) && null != exam && exam.getExamTaskThreeEndTime().getTime() < System.currentTimeMillis()) {
|
|
|
return JsonResult.failMessage("提交失败,考试任务三已结束");
|
|
|
}
|
|
|
|
|
|
List<Future<Boolean>> results = new ArrayList<>();
|
|
|
results.add(pool.submit(new TaskCallableForET3Q(condition, student, exam, examTaskThreeQuestion, examTaskThreeQuestionStep)));
|
|
|
|
|
|
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
//考试任务三答卷 线程处理
|
|
|
private class TaskCallableForET3Q implements Callable<Boolean> {
|
|
|
ExamTaskThreeQuestionStepQuery condition;
|
|
|
Student student;
|
|
|
Exam exam;
|
|
|
ExamTaskThreeQuestion examTaskThreeQuestion;
|
|
|
ExamTaskThreeQuestionStep examTaskThreeQuestionStep;
|
|
|
|
|
|
public TaskCallableForET3Q(ExamTaskThreeQuestionStepQuery condition, Student student, Exam exam, ExamTaskThreeQuestion examTaskThreeQuestion, ExamTaskThreeQuestionStep examTaskThreeQuestionStep) {
|
|
|
this.condition = condition;
|
|
|
this.student = student;
|
|
|
this.exam = exam;
|
|
|
this.examTaskThreeQuestion = examTaskThreeQuestion;
|
|
|
this.examTaskThreeQuestionStep = examTaskThreeQuestionStep;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean call() {
|
|
|
ExamStudents examStudents = new ExamStudents();
|
|
|
examStudents.setExamId(exam.getExamId());
|
|
|
examStudents.setStudentsId(student.getStudentId());
|
|
|
examStudents.setExamStudentsId(examTaskThreeQuestion.getExamStudentsId());
|
|
|
List<ExamStudents> examStudentsList = examStudentsService.getValues(examStudents);
|
|
|
|
|
|
if (null != examStudentsList && examStudentsList.size() > 0) {//判断答案和提交学员是否统一
|
|
|
if (TimeTool.getTime(condition.getAddTime()).getTime() <= exam.getExamTaskThreeEndTime().getTime()) {
|
|
|
|
|
|
BigDecimal score = BigDecimal.ZERO;
|
|
|
String competitionTaskThreeQuestionStepAnswer = examTaskThreeQuestionStep.getExamTaskThreeQuestionStepAnswer();
|
|
|
|
|
|
|
|
|
List<String> studentAnswerList = new ArrayList<>();
|
|
|
try {
|
|
|
studentAnswerList = JSON.parseArray(condition.getStudentAnswer(), String.class);
|
|
|
} catch (Exception e) {
|
|
|
try {
|
|
|
studentAnswerList.add(JSONObject.parseObject(condition.getStudentAnswer(), String.class));
|
|
|
} catch (Exception e1) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//将学生答案替换到题目中
|
|
|
String studentAnswer = examTaskThreeQuestionStep.getExamTaskThreeQuestionStepQuestion();
|
|
|
for (int i = 0; null != studentAnswerList && i < studentAnswerList.size(); i++) {
|
|
|
String answer = StringUtils.isNotBlank(studentAnswerList.get(i)) ? studentAnswerList.get(i) : "";
|
|
|
studentAnswer = studentAnswer.replaceFirst("___", answer.trim());
|
|
|
}
|
|
|
|
|
|
Double d = ToolUtils.judge(competitionTaskThreeQuestionStepAnswer, studentAnswer);
|
|
|
if (d == 100.0) {//TODO 暂定99%以上相似为正确
|
|
|
score = examTaskThreeQuestionStep.getExamTaskThreeQuestionStepScore();
|
|
|
}
|
|
|
|
|
|
ExamTaskThreeQuestionStep ct3qStep = new ExamTaskThreeQuestionStep();
|
|
|
ct3qStep.setExamTaskThreeQuestionStepId(condition.getExamTaskThreeQuestionStepId());
|
|
|
ct3qStep.setStudentAnswer(condition.getStudentAnswer());
|
|
|
ct3qStep.setExamTaskThreeQuestionStepGetScore(score);
|
|
|
examTaskThreeQuestionStepService.updateTemplate(ct3qStep);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//更新分值
|
|
|
ExamTaskThreeQuestionStepQuery examTaskThreeQuestionStepQuery = new ExamTaskThreeQuestionStepQuery();
|
|
|
examTaskThreeQuestionStepQuery.setExamId(exam.getExamId());
|
|
|
examTaskThreeQuestionStepQuery.setStudentsId(student.getStudentId());
|
|
|
|
|
|
BigDecimal totalScore = examTaskThreeQuestionStepService.getTotalScoreByQuery(examTaskThreeQuestionStepQuery);
|
|
|
|
|
|
examStudents = new ExamStudents();
|
|
|
examStudents.setExamId(exam.getExamId());
|
|
|
examStudents.setStudentsId(student.getStudentId());
|
|
|
examStudents.setExamTaskThreeFraction(totalScore);
|
|
|
examStudents.setExamTaskThreeFinishTime(((Integer) 1).equals(condition.getBeSubmitted()) ? new Date() : null);//判断是否是交卷;
|
|
|
examStudentsService.updateTotalScore(examStudents);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//练习实训 答题记录
|
|
|
public JsonResult setStudentQuestionLog(StudentQuestionLogQuery studentQuestionLogQuery) {
|
|
|
if (null == studentQuestionLogQuery.getResourcesQuestionId() && null == studentQuestionLogQuery.getResourcesCompetitionStepId() && null == studentQuestionLogQuery.getResourcesTrainingStepId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
if (null == studentQuestionLogQuery.getStudentId()) {
|
|
|
return JsonResult.failMessage("请登录后再操作");
|
|
|
}
|
|
|
studentQuestionLogQuery.setStudentQuestionLogAddTime(new Date());
|
|
|
|
|
|
|
|
|
List<Future<Boolean>> results = new ArrayList<>();
|
|
|
results.add(pool.submit(new TaskStudentQuestionLog(studentQuestionLogQuery)));
|
|
|
|
|
|
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
//答题记录 线程处理
|
|
|
private class TaskStudentQuestionLog implements Callable<Boolean> {
|
|
|
StudentQuestionLogQuery studentQuestionLogQuery;
|
|
|
|
|
|
public TaskStudentQuestionLog(StudentQuestionLogQuery studentQuestionLogQuery) {
|
|
|
this.studentQuestionLogQuery = studentQuestionLogQuery;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Boolean call() {
|
|
|
|
|
|
studentQuestionLogQuery.setStudentQuestionLogId(null);
|
|
|
|
|
|
StudentQuestionLog studentQuestionLog = studentQuestionLogQuery.pojo();
|
|
|
List<StudentQuestionLog> studentQuestionLogList = studentQuestionLogService.getValues(studentQuestionLog);
|
|
|
if (null != studentQuestionLogList && studentQuestionLogList.size() > 0) {
|
|
|
studentQuestionLog = studentQuestionLogList.get(0);
|
|
|
} else {
|
|
|
studentQuestionLogService.insert(studentQuestionLog);
|
|
|
}
|
|
|
|
|
|
StudentQuestionLogAnswer studentQuestionLogAnswer = new StudentQuestionLogAnswer();
|
|
|
studentQuestionLogAnswer.setStudentQuestionLogId(studentQuestionLog.getStudentQuestionLogId());
|
|
|
studentQuestionLogAnswer.setStudentAnswer(studentQuestionLogQuery.getStudentAnswer());
|
|
|
studentQuestionLogAnswer.setAnswerAddTime(studentQuestionLogQuery.getStudentQuestionLogAddTime());
|
|
|
studentQuestionLogAnswerService.save(studentQuestionLogAnswer);
|
|
|
|
|
|
StudentQuestionLogInfo studentQuestionLogInfo = new StudentQuestionLogInfo();
|
|
|
studentQuestionLogInfo.setStudentQuestionLogId(studentQuestionLog.getStudentQuestionLogId());
|
|
|
studentQuestionLogInfo.setQuestionFraction(studentQuestionLogQuery.getQuestionFraction());
|
|
|
studentQuestionLogInfo.setStudentFraction(studentQuestionLogQuery.getStudentFraction());
|
|
|
studentQuestionLogInfo.setStudentQuestionLogAddTime(studentQuestionLogQuery.getStudentQuestionLogAddTime());
|
|
|
studentQuestionLogInfoService.save(studentQuestionLogInfo);
|
|
|
|
|
|
//错题数据
|
|
|
if (studentQuestionLogQuery.getQuestionFraction().equals(studentQuestionLogQuery.getStudentFraction())) {
|
|
|
//查出错题,看看没有搞头
|
|
|
WrongQuestion wrongQuestion = studentQuestionLogQuery.pojo2WrongQuestion();
|
|
|
|
|
|
List<WrongQuestion> wrongQuestionList = wrongQuestionService.getValues(wrongQuestion);
|
|
|
if (null != wrongQuestionList && wrongQuestionList.size() > 0) {
|
|
|
//做对了,删除
|
|
|
wrongQuestionService.deleteWrongQuestion(wrongQuestionList.get(0).getStudentQuestionLogId().toString());
|
|
|
}
|
|
|
} else {
|
|
|
WrongQuestion wrongQuestion = studentQuestionLogQuery.pojo2WrongQuestion();
|
|
|
wrongQuestionService.save(wrongQuestion);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//记录答辩数据
|
|
|
public JsonResult updateDefenceData(StudentDefenceLogQuery studentDefenceLogQuery, FileEntity fileEntity) {
|
|
|
if (null == fileEntity) {
|
|
|
return JsonResult.failMessage("请上传文件");
|
|
|
}
|
|
|
if (null == studentDefenceLogQuery.getResourcesTrainingId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
|
|
|
studentDefenceLogQuery.setStudentDefenceLogId(null);
|
|
|
|
|
|
StudentDefenceLog studentDefenceLog = studentDefenceLogQuery.pojo();
|
|
|
List<StudentDefenceLog> studentDefenceLogList = studentDefenceLogService.getValues(studentDefenceLog);
|
|
|
if (null != studentDefenceLogList && studentDefenceLogList.size() > 0) {
|
|
|
studentDefenceLog = studentDefenceLogList.get(0);
|
|
|
} else {
|
|
|
studentDefenceLogService.insert(studentDefenceLog);
|
|
|
}
|
|
|
|
|
|
StudentDefenceLogInfo studentDefenceLogInfo = new StudentDefenceLogInfo();
|
|
|
studentDefenceLogInfo.setStudentDefenceLogId(studentDefenceLog.getStudentDefenceLogId());
|
|
|
studentDefenceLogInfo.setStudentDefenceData(fileEntity.getUrl());
|
|
|
studentDefenceLogInfo.setStudentDefenceAddTime(new Date());
|
|
|
studentDefenceLogInfoService.save(studentDefenceLogInfo);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
|
|
|
public JsonResult updateDefenceNote(StudentDefenceLogQuery studentDefenceLogQuery) {
|
|
|
if (null == studentDefenceLogQuery.getResourcesTrainingId()) {
|
|
|
return JsonResult.failMessage("参数丢失");
|
|
|
}
|
|
|
|
|
|
studentDefenceLogQuery.setStudentDefenceLogId(null);
|
|
|
|
|
|
StudentDefenceLog studentDefenceLog = studentDefenceLogQuery.pojo();
|
|
|
List<StudentDefenceLog> studentDefenceLogList = studentDefenceLogService.getValues(studentDefenceLog);
|
|
|
if (null != studentDefenceLogList && studentDefenceLogList.size() > 0) {
|
|
|
studentDefenceLog = studentDefenceLogList.get(0);
|
|
|
} else {
|
|
|
studentDefenceLogService.insert(studentDefenceLog);
|
|
|
}
|
|
|
|
|
|
StudentDefenceLogNote studentDefenceLogNote = new StudentDefenceLogNote();
|
|
|
studentDefenceLogNote.setStudentDefenceLogId(studentDefenceLog.getStudentDefenceLogId());
|
|
|
|
|
|
List<StudentDefenceLogNote> studentDefenceLogNoteList = studentDefenceLogNoteService.getValues(studentDefenceLogNote);
|
|
|
if (null != studentDefenceLogNoteList && studentDefenceLogNoteList.size() > 0) {
|
|
|
studentDefenceLogNote.setStudentDefenceLogNoteId(studentDefenceLogNoteList.get(0).getStudentDefenceLogNoteId());
|
|
|
studentDefenceLogNote.setNoteComment(studentDefenceLogQuery.getNoteComment());
|
|
|
studentDefenceLogNote.setNoteCommentOriginal(studentDefenceLogQuery.getNoteCommentOriginal());
|
|
|
studentDefenceLogNote.setNoteAddTime(new Date());
|
|
|
studentDefenceLogNoteService.updateTemplate(studentDefenceLogNote);
|
|
|
} else {
|
|
|
studentDefenceLogNote.setNoteComment(studentDefenceLogQuery.getNoteComment());
|
|
|
studentDefenceLogNote.setNoteCommentOriginal(studentDefenceLogQuery.getNoteCommentOriginal());
|
|
|
studentDefenceLogNote.setNoteAddTime(new Date());
|
|
|
studentDefenceLogNoteService.save(studentDefenceLogNote);
|
|
|
}
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getStudentInfoByClassId(String classId) {
|
|
|
//逗号分隔classid并转换成数据
|
|
|
String[] split = classId.split(",");
|
|
|
List<Integer> classIds = new ArrayList<>();
|
|
|
for (String s : split) {
|
|
|
classIds.add(Integer.parseInt(s));
|
|
|
}
|
|
|
|
|
|
return studentDao.getStudentInfoByClassId(classId);
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getStudentInfoByKeyword(String keyword, Long schoolId) {
|
|
|
return studentDao.getStudentInfoByKeyword(keyword, schoolId);
|
|
|
}
|
|
|
|
|
|
public PageQuery<Map<String, Object>> pagedListStudentInfoByClassId(String classIds, Integer pageNo, Integer pageSize) {
|
|
|
PageQuery pageQuery = new PageQuery();
|
|
|
pageQuery.setPageSize(pageSize);
|
|
|
pageQuery.setPageNumber(pageNo);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("classIds", classIds);
|
|
|
pageQuery.setParas(map);
|
|
|
return studentDao.pagedListStudentInfoByClassId(pageQuery);
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> findAllBySchoolId(Long schoolId) {
|
|
|
List<Map<String, Object>> mapList = studentDao.findAllBySchoolId(schoolId);
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
//将内部元素弄成驼峰
|
|
|
for (Map<String, Object> map : mapList) {
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
data.put("studentNo", map.get("studentno"));
|
|
|
data.put("name", map.get("name"));
|
|
|
data.put("classId", map.get("classid"));
|
|
|
dataList.add(data);
|
|
|
}
|
|
|
return dataList;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> findAllSonSystemBySchoolId(Long schoolId) {
|
|
|
List<Map<String, Object>> mapList = studentDao.findAllSonSystemAllBySchoolId(schoolId);
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
//将内部元素弄成驼峰
|
|
|
for (Map<String, Object> map : mapList) {
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
data.put("studentNo", map.get("studentno"));
|
|
|
data.put("name", map.get("name"));
|
|
|
data.put("classId", map.get("classid"));
|
|
|
dataList.add(data);
|
|
|
}
|
|
|
return dataList;
|
|
|
}
|
|
|
|
|
|
public List<String> findStudentNoByClassId(Long classId) {
|
|
|
return studentDao.findStudentNoByClassId(classId);
|
|
|
}
|
|
|
|
|
|
public List<Student> getAll() {
|
|
|
return studentDao.all();
|
|
|
}
|
|
|
|
|
|
//查询没有基础资金的学生账号
|
|
|
public List<Student> getNoBaseStudent() {
|
|
|
return studentDao.getNoBaseStudent();
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> findAllStudent() {
|
|
|
return studentDao.findAllStudent();
|
|
|
}
|
|
|
|
|
|
public Student getByOldId(Long oldId) {
|
|
|
return studentDao.getByOldId(oldId);
|
|
|
}
|
|
|
|
|
|
|
|
|
public void deleteById1(Long studentId) {
|
|
|
sqlManager.deleteById(Student.class, studentId);
|
|
|
}
|
|
|
//查询资产数据没有32条的数据
|
|
|
public List<Student> getNoAssetStudent() {
|
|
|
return studentDao.getNoAssetStudent();
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getMapByStudentIdForForeign(Long studentId){
|
|
|
return studentDao.getMapByStudentIdForForeign(studentId);
|
|
|
}
|
|
|
} |