mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
Compare commits
21 Commits
master
...
zcwy0622-y
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
897a44e2c3 | ||
|
|
a019726181 | ||
|
|
3b34cc1bde | ||
|
|
be18e35583 | ||
|
|
bd25fc1d1a | ||
|
|
91b0b899b0 | ||
|
|
983313e845 | ||
|
|
f4c1bd7eed | ||
|
|
0ac6622526 | ||
|
|
9a83f64e38 | ||
|
|
26a2a8e709 | ||
|
|
170dc45c64 | ||
|
|
5594e07264 | ||
|
|
13b5e6ab4c | ||
|
|
e144fde444 | ||
|
|
a4f260b99a | ||
|
|
de7d26f447 | ||
|
|
e2e0aeb9cb | ||
|
|
bcdc784e7d | ||
|
|
7c4a6feb78 | ||
|
|
aa245e52c6 |
@@ -4,23 +4,22 @@ import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.*;
|
||||
import com.xboe.api.vo.*;
|
||||
import com.xboe.module.course.vo.StudyCourseVo;
|
||||
import com.xboe.module.course.vo.TeacherInfoVo;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.dict.entity.DictDto;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.system.user.dao.UserDao;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -62,6 +61,13 @@ public class ThirdApi {
|
||||
|
||||
@Value("${coursesuilt.getStudyStatus}")
|
||||
private String getStudyStatus;
|
||||
|
||||
@Value("${userBasic.getUserIdByWorkNum}")
|
||||
private String getUserIdByWorkNum;
|
||||
|
||||
@Value("${coursesuilt.syncExamScoreToCourseSuite}")
|
||||
private String syncExamScoreToCourseSuite;
|
||||
|
||||
//获取例外人员的id
|
||||
public List<String> getUserId(){
|
||||
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
|
||||
@@ -217,8 +223,41 @@ public class ThirdApi {
|
||||
List<UserDynamic> list = a.getResult().getList();
|
||||
System.out.println(" list = " +list.size());
|
||||
System.out.println(" list = " +list);
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, String> getUserIdByWorkNum(String token, List<String> workNumList) {
|
||||
// 将workNum列表转换为逗号分隔的字符串
|
||||
String workNums = workNumList.stream()
|
||||
.collect(Collectors.joining(","));
|
||||
// 构建请求URL
|
||||
String url = getUserIdByWorkNum+"?workNums=" + workNums;
|
||||
String respStr = Optional.ofNullable(
|
||||
HttpRequest.get(url)
|
||||
.header("token", token)
|
||||
.execute().body()
|
||||
).orElseThrow(() -> new RuntimeException("Token校验失败"));
|
||||
// 解析JSON字符串为HashMap
|
||||
GetUserIdByWorkNumResult getUserIdByWorkNumResult = JSONUtil.parseObj(respStr).toBean(GetUserIdByWorkNumResult.class);
|
||||
HashMap<String, String> result = getUserIdByWorkNumResult.getResult();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void syncExamScoreToCourseSuite(AloneExam aloneExam,String token) {
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer())
|
||||
.create();
|
||||
|
||||
String json = gson.toJson(aloneExam);
|
||||
String resp = HttpRequest.post(syncExamScoreToCourseSuite)
|
||||
.body(json)
|
||||
.header("token", token)
|
||||
.execute()
|
||||
.body();
|
||||
|
||||
if (StringUtils.isBlank(resp)){
|
||||
return;
|
||||
}
|
||||
JSONUtil.toBean(resp, SyncExamScoreBean.class).success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CheckExamBandingBean {
|
||||
|
||||
private boolean show;
|
||||
private String version;
|
||||
private int code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
private boolean success;
|
||||
|
||||
public CheckExamBandingBean success() {
|
||||
if (this.code!=200) {
|
||||
log.error("获取绑定关系失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Auto-generated: 2022-12-10 14:3:18
|
||||
*
|
||||
* @author bejson.com (i@bejson.com)
|
||||
* @website http://www.bejson.com/java2pojo/
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GetUserIdByWorkNumResult {
|
||||
|
||||
private String error;
|
||||
private String message;
|
||||
private String permissions;
|
||||
private HashMap<String,String> result;
|
||||
private int status;
|
||||
private Date timestamp;
|
||||
|
||||
public GetUserIdByWorkNumResult success() {
|
||||
if (this.status != 200) {
|
||||
log.error("获取用户ID列表失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonElement;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonPrimitive;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonSerializationContext;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime> {
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(formatter.format(src));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SyncExamScoreBean {
|
||||
|
||||
private boolean show;
|
||||
private String version;
|
||||
private int code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
private boolean success;
|
||||
|
||||
public SyncExamScoreBean success() {
|
||||
if (this.code!=200) {
|
||||
log.error("同步考试到boe库失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.module.exam.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@@ -14,15 +15,12 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.xboe.module.exam.dto.SaveExamScoreDto;
|
||||
import com.xboe.module.exam.entity.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -41,9 +39,6 @@ import com.xboe.core.cache.IXaskCache;
|
||||
import com.xboe.core.cache.XaskCacheProvider;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.module.exam.dto.AloneExamExportDto;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
import com.xboe.module.exam.service.IAloneExamService;
|
||||
import com.xboe.module.exam.service.IExamPaperService;
|
||||
import com.xboe.module.exam.service.IExamTestService;
|
||||
@@ -553,6 +548,7 @@ public class AloneExamApi extends ApiBaseController {
|
||||
//转化成百分数
|
||||
//answer.setScore(this.calculateScore(detail));
|
||||
service.submit(answer,scoreType);
|
||||
service.syncExamScoreToCourseSuite(answer, request);
|
||||
return success(map);
|
||||
} catch (Exception e) {
|
||||
log.error("提交答卷错误", e);
|
||||
@@ -707,4 +703,19 @@ public class AloneExamApi extends ApiBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param saveExamScoreDtoList
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@PostMapping("/examScoreBatchAdd")
|
||||
public JsonResponse examScoreBatchAdd(HttpServletRequest request, @RequestBody List<SaveExamScoreDto> saveExamScoreDtoList){
|
||||
service.examScoreBatchAdd(request, saveExamScoreDtoList);
|
||||
return success("导入成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.xboe.module.exam.api;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
@@ -19,6 +19,8 @@ import com.xboe.module.exam.service.IExamTestService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考试
|
||||
* */
|
||||
@@ -29,6 +31,9 @@ public class ExamTestApi extends ApiBaseController {
|
||||
|
||||
@Resource
|
||||
private IExamTestService examTestService;
|
||||
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
/**
|
||||
*查询考试,分页,搜索,资源归属,状态
|
||||
@@ -111,10 +116,16 @@ public class ExamTestApi extends ApiBaseController {
|
||||
* */
|
||||
@GetMapping("/delete")
|
||||
@AutoLog(module = "考试",action = "删除考试",info = "删除考试")
|
||||
public JsonResponse<Boolean> delete(String id){
|
||||
public JsonResponse<Boolean> delete(String id, HttpServletRequest request){
|
||||
if(StringUtil.isBlank(id)){
|
||||
return badRequest("缺少必要参数");
|
||||
}
|
||||
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtil.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
|
||||
try {
|
||||
examTestService.delete(id);
|
||||
return success(true);
|
||||
@@ -161,4 +172,21 @@ public class ExamTestApi extends ApiBaseController {
|
||||
return error("上下级失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 引用关系移除
|
||||
* */
|
||||
@PostMapping("/removeRel")
|
||||
public JsonResponse<Boolean> removeRel(@RequestParam List<String> ids){
|
||||
if(CollectionUtil.isEmpty(ids)){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
try {
|
||||
examTestService.removeRel(ids);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("引用关系移除异常",e);
|
||||
return error("引用关系移除异常",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.xboe.module.exam.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 单独的考虑答卷信息
|
||||
*/
|
||||
@Data
|
||||
public class SaveExamScoreDto {
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 考试id
|
||||
*/
|
||||
private String testId;
|
||||
|
||||
// /**
|
||||
// * 考试名称
|
||||
// */
|
||||
// private String testName;
|
||||
|
||||
// /**
|
||||
// * 考试时长 分钟
|
||||
// */
|
||||
// private Integer testDuration;
|
||||
|
||||
/**
|
||||
* 试题排列 1试题乱序,2选项乱序,3全部乱序
|
||||
*/
|
||||
private Integer arrange;
|
||||
|
||||
// /**
|
||||
// * 及格线
|
||||
// */
|
||||
// private Integer passLine;
|
||||
|
||||
/**
|
||||
* 账户的代码,用于区别于同姓名的用户
|
||||
*/
|
||||
private String workNum;
|
||||
|
||||
|
||||
/**
|
||||
* 独立考试任务的id
|
||||
*/
|
||||
private String aloneId;
|
||||
|
||||
/**
|
||||
* 试卷总分
|
||||
*/
|
||||
@Column(name = "total_score")
|
||||
private Float totalScore;
|
||||
|
||||
|
||||
// /**
|
||||
// * 答卷内容
|
||||
// */
|
||||
// @Column(name = "answer_json", columnDefinition = "mediumtext")
|
||||
// private String answerJson;
|
||||
|
||||
// todo by yyk 2024-05-17 14:10:32 确定分数
|
||||
/**
|
||||
* 用户的实际得分
|
||||
*/
|
||||
private Float realScore;
|
||||
|
||||
// /**
|
||||
// * 用时秒
|
||||
// */
|
||||
// private Integer useMinute;
|
||||
|
||||
|
||||
/**
|
||||
* 最终成绩,如果是百分制,用户的实际得分会换算为百分制
|
||||
*/
|
||||
private Float score;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
|
||||
// /**
|
||||
// * 完成状态
|
||||
// */
|
||||
// private Integer status;
|
||||
|
||||
// /**
|
||||
// * 考试次数
|
||||
// */
|
||||
// private Integer times;
|
||||
|
||||
|
||||
// /**
|
||||
// * 记录最后的操作时间
|
||||
// */
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
|
||||
// private LocalDateTime lastTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -65,6 +65,7 @@ public class AloneExam extends IdBaseEntity {
|
||||
private String ucode;
|
||||
|
||||
/**关联类型*/
|
||||
/**关联类型 新增关联类型14,代表成长路径图*/
|
||||
@Column(name = "ref_type", length = 30)
|
||||
private String refType;
|
||||
|
||||
|
||||
@@ -178,4 +178,14 @@ public class ExamTest extends BaseEntity {
|
||||
|
||||
@Transient
|
||||
private String paperName;
|
||||
|
||||
/** 关联类型,1、项目 2、学习路径图 3、面授课 14、成长路径图 */
|
||||
@Column(name = "ref_type")
|
||||
private Integer refType;
|
||||
|
||||
@Column(name = "ref_id")
|
||||
private String refId;
|
||||
|
||||
@Column(name = "ref_status")
|
||||
private Integer refStatus;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ import java.util.Map;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.module.exam.dto.SaveExamScoreDto;
|
||||
import com.xboe.module.exam.dto.TestUserDto;
|
||||
import com.xboe.module.exam.dto.TestUserQuery;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.vo.AloneExamQuery;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 独立考试的处理。此信息无删除操作,更新也只是更新answerJson字段
|
||||
@@ -92,10 +94,18 @@ public interface IAloneExamService {
|
||||
|
||||
/**
|
||||
* 提交考试
|
||||
*
|
||||
* @param aea
|
||||
*/
|
||||
void submit(AloneExamAnswer aea,Integer scoreType);
|
||||
|
||||
void submit(AloneExamAnswer aea, Integer scoreType);
|
||||
|
||||
/**
|
||||
* 同步考试成绩
|
||||
* @param aea
|
||||
* @param request
|
||||
*/
|
||||
void syncExamScoreToCourseSuite(AloneExamAnswer aea, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 更新答案
|
||||
* @param id
|
||||
@@ -156,5 +166,7 @@ public interface IAloneExamService {
|
||||
* @throws Exception
|
||||
*/
|
||||
PageList<TestUserDto> findTestUserAnswers(TestUserQuery params) throws Exception;
|
||||
|
||||
|
||||
void examScoreBatchAdd(HttpServletRequest request, List<SaveExamScoreDto> saveExamScoreDtoList);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.xboe.module.exam.service;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IExamTestService {
|
||||
/**
|
||||
* 分页查,状态,搜索,资源归属
|
||||
@@ -51,4 +53,5 @@ public interface IExamTestService {
|
||||
* */
|
||||
void enabled(String id,Boolean enabled);
|
||||
|
||||
void removeRel(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
package com.xboe.module.exam.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.module.exam.dao.ExamTestDao;
|
||||
import com.xboe.module.exam.dto.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
@@ -20,31 +30,40 @@ import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.module.exam.dao.AloneExamAnswerDao;
|
||||
import com.xboe.module.exam.dao.AloneExamDao;
|
||||
import com.xboe.module.exam.dto.TestUserAnswerDto;
|
||||
import com.xboe.module.exam.dto.TestUserDto;
|
||||
import com.xboe.module.exam.dto.TestUserQuery;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
import com.xboe.module.exam.service.IAloneExamService;
|
||||
import com.xboe.module.exam.vo.AloneExamQuery;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
@Service
|
||||
public class AloneExamServiceImpl implements IAloneExamService{
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AloneExamServiceImpl.class);
|
||||
@Resource
|
||||
AloneExamAnswerDao dao;
|
||||
|
||||
@Resource
|
||||
AloneExamDao aeDao;
|
||||
|
||||
@Autowired
|
||||
private ExamTestDao examTestDao;
|
||||
|
||||
@Autowired
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AloneExamAnswer aea){
|
||||
dao.save(aea);
|
||||
AloneExam ae=aeDao.findOne(FieldFilters.eq("aid", aea.getAid()),FieldFilters.eq("testId", aea.getTestId()));
|
||||
int currentTimes = ae.getTimes() != null ? ae.getTimes() : 0;
|
||||
//更新状态
|
||||
aeDao.update(UpdateBuilder.from(AloneExam.class)
|
||||
.addUpdateField("status", AloneExam.STATUS_NORMAL)
|
||||
.addUpdateField("times", currentTimes+1)
|
||||
.addFilter(FieldFilters.eq("aid", aea.getAid()))
|
||||
.addFilter(FieldFilters.eq("testId", aea.getTestId()))
|
||||
.addFilter(FieldFilters.eq("status",AloneExam.STATUS_NONE))
|
||||
@@ -53,8 +72,8 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void submit(AloneExamAnswer aea,Integer scoreType){
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void submit(AloneExamAnswer aea, Integer scoreType){
|
||||
//dao.update(aea);
|
||||
aea.setStatus(AloneExamAnswer.STATUS_FINISH);
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
@@ -102,6 +121,27 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
// }
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void syncExamScoreToCourseSuite(AloneExamAnswer aea, HttpServletRequest request) {
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
|
||||
String finalToken = token;
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
AloneExam aloneExam = aeDao.findOne(FieldFilters.eq("aid", aea.getAid()), FieldFilters.eq("testId", aea.getTestId()));
|
||||
if (aloneExam.getRefType().equals("14")){
|
||||
thirdApi.syncExamScoreToCourseSuite(aloneExam, finalToken);
|
||||
}
|
||||
return "完成结果";
|
||||
}).exceptionally(ex -> {
|
||||
log.error("异步操作中发生错误: " + ex.getMessage(), ex);
|
||||
return "发生错误";
|
||||
}).thenAccept(result -> {
|
||||
log.info("同步考试成绩到课程项目完成:" + result);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -427,4 +467,86 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
rs.setPageSize(params.getPageSize());
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
|
||||
@Override
|
||||
public void examScoreBatchAdd(HttpServletRequest request, List<SaveExamScoreDto> saveExamScoreDtoList) {
|
||||
List<String> workNumList = saveExamScoreDtoList.stream().map(SaveExamScoreDto::getWorkNum).collect(Collectors.toList());
|
||||
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
HashMap<String, String> userIdAndWorkNumMap = thirdApi.getUserIdByWorkNum(token, workNumList);
|
||||
|
||||
saveExamScoreDtoList.forEach(examScoreDto -> {
|
||||
TransactionStatus status = null; // 事务状态
|
||||
|
||||
try {
|
||||
// 获取事务定义
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||
// 设置事务隔离级别
|
||||
def.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_READ_COMMITTED);
|
||||
// 设置事务传播行为
|
||||
def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRED);
|
||||
// 获取事务状态
|
||||
status = transactionManager.getTransaction(def);
|
||||
|
||||
AloneExamAnswer aloneExamAnswer = new AloneExamAnswer();
|
||||
BeanUtils.copyProperties(examScoreDto, aloneExamAnswer);
|
||||
|
||||
String userId = userIdAndWorkNumMap.get(examScoreDto.getWorkNum());
|
||||
aloneExamAnswer.setAid(userId);
|
||||
aloneExamAnswer.setName(examScoreDto.getUserName());
|
||||
aloneExamAnswer.setUcode(examScoreDto.getWorkNum());
|
||||
aloneExamAnswer.setStatus(AloneExamAnswer.STATUS_FINISH);
|
||||
// aloneExamAnswer.setUseSecond(examScoreDto.getUseMinute()*60);
|
||||
|
||||
ExamTest examTest = examTestDao.get(examScoreDto.getTestId());
|
||||
aloneExamAnswer.setPassLine(examTest.getPassLine());
|
||||
aloneExamAnswer.setArrange(examTest.getArrange());
|
||||
aloneExamAnswer.setTestDuration(examTest.getTestDuration());
|
||||
|
||||
// 获取考试任务ID
|
||||
AloneExam aloneExam=aeDao.findOne(FieldFilters.eq("aid", userId),FieldFilters.eq("testId", examScoreDto.getTestId()));
|
||||
aloneExamAnswer.setAloneId(aloneExam.getId());
|
||||
// 添加答卷
|
||||
dao.save(aloneExamAnswer);
|
||||
|
||||
// 更新状态,状态是未完成的,这里会有问题
|
||||
int currentTimes = aloneExam.getTimes() != null ? aloneExam.getTimes() : 0;
|
||||
if(examTest.getScoringType()!=null && examTest.getScoringType()==2) {
|
||||
//最后一次的分数为准
|
||||
aeDao.update(UpdateBuilder.from(AloneExam.class)
|
||||
.addUpdateField("status", AloneExam.STATUS_FINISH)
|
||||
.addUpdateField("score", examScoreDto.getScore())
|
||||
.addUpdateField("times", currentTimes+1)
|
||||
.addFilter(FieldFilters.eq("aid", userId))
|
||||
.addFilter(FieldFilters.eq("testId", examScoreDto.getTestId()))
|
||||
.builder());
|
||||
} else {
|
||||
if (aloneExam.getStatus() == AloneExam.STATUS_FINISH) {
|
||||
if (aloneExam.getScore() < examScoreDto.getScore()) {
|
||||
aeDao.updateMultiFieldById(aloneExam.getId(), UpdateBuilder.create("score", examScoreDto.getScore()), UpdateBuilder.create("times", currentTimes+1));
|
||||
}
|
||||
} else {
|
||||
aeDao.updateMultiFieldById(aloneExam.getId(), UpdateBuilder.create("status", AloneExam.STATUS_FINISH), UpdateBuilder.create("score", examScoreDto.getScore()), UpdateBuilder.create("times", currentTimes+1));
|
||||
}
|
||||
}
|
||||
|
||||
// 提交事务
|
||||
transactionManager.commit(status);
|
||||
} catch (Exception e) {
|
||||
// 如果发生异常,回滚事务
|
||||
if (status != null && !status.isCompleted()) {
|
||||
transactionManager.rollback(status);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,4 +111,10 @@ public class ExamTestServiceImpl implements IExamTestService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRel(List<String> ids) {
|
||||
String idsStr = String.join(",", ids);
|
||||
examTestDao.sqlUpdate("update boe_exam_test set ref_status=0 where id in (?1)",idsStr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,7 @@ infrasApi.dict=${boe.domain}/infrasApi/dict/list
|
||||
manageApi.stu.offcourse=${boe.domain}/manageApi/stu/offcourse/getOffCourseId
|
||||
#获取离职教师id
|
||||
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
|
||||
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
||||
userBasic.getUserIdByWorkNum=${boe.domain}/userbasic/user/getUserIdByWorkNum
|
||||
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
||||
coursesuilt.checkBanding=${boe.domain}/manageApi/stu/task/exam/checkBanding
|
||||
coursesuilt.syncExamScoreToCourseSuite=${boe.domain}/manageApi/stu/task/exam/syncExamScoreToCourseSuite
|
||||
Reference in New Issue
Block a user