mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
Compare commits
72 Commits
zcwy0622-y
...
zcwy0716-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf476a23a0 | ||
|
|
687cd24de3 | ||
|
|
4687b353eb | ||
|
|
072ee25037 | ||
|
|
2f8163b0a3 | ||
|
|
5890f1b800 | ||
|
|
50942a9435 | ||
|
|
3ec7f587b3 | ||
|
|
885b203dd6 | ||
|
|
e6f4affa21 | ||
|
|
e4f845fdde | ||
|
|
c97cd3daab | ||
|
|
74f37b008d | ||
|
|
d0b1894c14 | ||
|
|
7e1e32a70e | ||
|
|
30f8d363fa | ||
|
|
338a709ebc | ||
|
|
650107aea1 | ||
|
|
4c6480b428 | ||
|
|
901aded0c3 | ||
|
|
e77ee34225 | ||
|
|
9373a95631 | ||
|
|
d81d4c474e | ||
|
|
2b3f59522c | ||
|
|
2f150449fe | ||
|
|
4f6fbff5e1 | ||
|
|
abef4c963e | ||
|
|
5e355986a0 | ||
|
|
13914ede08 | ||
|
|
7eb1dcd7c4 | ||
|
|
ea7ff473d0 | ||
|
|
9aaab480bf | ||
|
|
b0ac4951ad | ||
|
|
3e9eaf30cb | ||
|
|
9fbeea85c6 | ||
|
|
b2981cff8a | ||
|
|
dc2d144682 | ||
|
|
46b63c36eb | ||
|
|
312108e6c0 | ||
|
|
fee3f263bc | ||
|
|
16c755d14d | ||
|
|
69b6a50011 | ||
|
|
bed3bd7fae | ||
|
|
d60a1521f9 | ||
|
|
34db08d1a8 | ||
|
|
2822021f30 | ||
|
|
63d3844b76 | ||
|
|
e9645d631d | ||
|
|
588f527293 | ||
|
|
99df06481f | ||
|
|
921aa5909e | ||
|
|
d514450f23 | ||
|
|
00c1fe8c49 | ||
|
|
92aa649fa1 | ||
|
|
019d534956 | ||
|
|
b67d931741 | ||
|
|
1bd09c0f02 | ||
|
|
1794344829 | ||
|
|
952f47fdc6 | ||
|
|
f19b928bc9 | ||
|
|
df91242e1b | ||
|
|
7b2217c017 | ||
|
|
333f29f008 | ||
|
|
ba6cca93b3 | ||
|
|
d23bfbe159 | ||
|
|
17ab1add64 | ||
|
|
7c9c1987a3 | ||
|
|
da6ed5eed4 | ||
|
|
b108bc3e76 | ||
|
|
1abd059820 | ||
|
|
33fee46433 | ||
|
|
7d08954525 |
@@ -4,22 +4,24 @@ 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.module.exam.entity.ExamTest;
|
||||
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.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -62,12 +64,8 @@ public class ThirdApi {
|
||||
@Value("${coursesuilt.getStudyStatus}")
|
||||
private String getStudyStatus;
|
||||
|
||||
@Value("${userBasic.getUserIdByWorkNum}")
|
||||
private String getUserIdByWorkNum;
|
||||
|
||||
@Value("${coursesuilt.syncExamScoreToCourseSuite}")
|
||||
private String syncExamScoreToCourseSuite;
|
||||
|
||||
@Value("${manageApi.editExam}")
|
||||
private String editExam;
|
||||
//获取例外人员的id
|
||||
public List<String> getUserId(){
|
||||
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
|
||||
@@ -212,6 +210,14 @@ public class ThirdApi {
|
||||
return studyCourseResult.getResult();
|
||||
}
|
||||
|
||||
public void sqlUpdate(ExamTest examTest, String token) {
|
||||
examTest.setSysUpdateTime(null);
|
||||
examTest.setSysCreateTime(null);
|
||||
examTest.setPublishTime(null);
|
||||
String resp = Optional.ofNullable(HttpRequest.post(editExam).body(JSONUtil.toJsonStr(examTest)).header("token", token).execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
Opt.ofBlankAble(resp).map(t -> JSONUtil.toBean(t, DynamicBean.class).success());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String token = "eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJjb21wYW55Q29kZSI6IkMwMDEiLCJ1SWQiOiI5NjUzNDIwMjc0OTc2MDcxNjgiLCJjb21wYW55SWQiOiIxMDQxNjczOTc3Mzc5OTQ2NDk2IiwibG9naW5JZCI6IjE2ODg0NDg5MjIwNzY0OTE3NzgiLCJpc3MiOiJodHRwOi8vdS5ib2UuY29tIiwiR2l2ZW5OYW1lIjoiYm9ldSIsImV4cCI6MTY5MTM5OTc2NzU1OCwidXNlck5hbWUiOiLmnY7njonlhrAiLCJ1c2VySWQiOiI2QjA0OUZBRi1DMzE0LTdDQ0YtMEQyOC0wRDIzRjRDNDI1MzEifQ==.8b52dcf4d48a790ed258b9ca2b279bb269f5301722095382fbd352705b51c893";
|
||||
String resp = Optional.ofNullable(HttpRequest.post("https://u-pre.boe.com/statApi/xboe/m/stat/userdynamic/list").body(JSONUtil.toJsonStr(UserdynamicParam.builder().
|
||||
@@ -223,41 +229,10 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
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,10 +1,13 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class CourseContentDao extends BaseDao<CourseContent> {
|
||||
|
||||
@@ -20,4 +23,5 @@ public class CourseContentDao extends BaseDao<CourseContent> {
|
||||
int count=count(hql, courseId);
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,21 @@ public class CourseContent extends BaseEntity {
|
||||
this.contentType=contentType;
|
||||
this.contentRefId=contentRefId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CourseContent{" +
|
||||
"rid='" + rid + '\'' +
|
||||
", typeId='" + typeId + '\'' +
|
||||
", courseId='" + courseId + '\'' +
|
||||
", csectionId='" + csectionId + '\'' +
|
||||
", sortIndex=" + sortIndex +
|
||||
", contentType=" + contentType +
|
||||
", contentName='" + contentName + '\'' +
|
||||
", contentRefId='" + contentRefId + '\'' +
|
||||
", content='" + content + '\'' +
|
||||
", duration=" + duration +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,6 +214,12 @@ public class CourseAuditServiceImpl implements ICourseAuditService{
|
||||
UpdateBuilder.create("lastState", CourseHRBPAudit.STATUS_PASS)
|
||||
);
|
||||
|
||||
//设置课程状态已审核完成,这里是管理员的审核
|
||||
courseDao.updateMultiFieldById(courseId,
|
||||
UpdateBuilder.create("published", pass),
|
||||
UpdateBuilder.create("erasable", false), //设置以后不能物理删除了
|
||||
UpdateBuilder.create("publishTime", LocalDateTime.now()));
|
||||
|
||||
//发布到全文检索中
|
||||
Course c=courseDao.get(courseId);
|
||||
publishUtil.fullTextPublish(c);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.xboe.module.exam.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@@ -15,12 +14,15 @@ 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.*;
|
||||
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 com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -39,6 +41,9 @@ 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;
|
||||
@@ -548,7 +553,6 @@ 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);
|
||||
@@ -703,19 +707,4 @@ 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("导入成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@ package com.xboe.module.exam.api;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
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 com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
@@ -19,8 +23,6 @@ import com.xboe.module.exam.service.IExamTestService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考试
|
||||
* */
|
||||
@@ -31,10 +33,8 @@ public class ExamTestApi extends ApiBaseController {
|
||||
|
||||
@Resource
|
||||
private IExamTestService examTestService;
|
||||
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
ThirdApi thirdApi;
|
||||
/**
|
||||
*查询考试,分页,搜索,资源归属,状态
|
||||
**/
|
||||
@@ -82,16 +82,33 @@ public class ExamTestApi extends ApiBaseController {
|
||||
* */
|
||||
@PostMapping("update")
|
||||
@AutoLog(module = "考试",action = "修改考试",info = "修改考试")
|
||||
public JsonResponse<ExamTest> update(@RequestBody ExamTest examTest){
|
||||
public JsonResponse<ExamTest> update(@RequestBody ExamTest examTest, HttpServletRequest request){
|
||||
if(StringUtil.isBlank(examTest.getTestName())){
|
||||
return badRequest("标题为空");
|
||||
}
|
||||
|
||||
// 确保examTest有一个有效的主键ID(如果适用)
|
||||
// 这取决于您的业务逻辑是否允许更新主键
|
||||
// 通常,更新操作不会改变主键
|
||||
if (examTest.getId() == null) {
|
||||
return badRequest("更新操作需要有效的主键ID");
|
||||
}
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
try {
|
||||
examTestService.update(examTest);
|
||||
thirdApi.sqlUpdate(examTest,token);
|
||||
return success(examTest);
|
||||
} catch (ConstraintViolationException e) {
|
||||
// 捕获约束违反异常,并返回一个更具体的错误消息
|
||||
log.error("修改失败,违反了约束条件", e);
|
||||
return error("修改失败,违反了约束条件(可能是主键已存在)");
|
||||
} catch (Exception e) {
|
||||
log.error("修改失败",e);
|
||||
return error("修改失败",e.getMessage());
|
||||
// 捕获其他所有异常
|
||||
log.error("修改失败", e);
|
||||
return error("修改失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
/**、
|
||||
@@ -116,16 +133,10 @@ public class ExamTestApi extends ApiBaseController {
|
||||
* */
|
||||
@GetMapping("/delete")
|
||||
@AutoLog(module = "考试",action = "删除考试",info = "删除考试")
|
||||
public JsonResponse<Boolean> delete(String id, HttpServletRequest request){
|
||||
public JsonResponse<Boolean> delete(String id){
|
||||
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);
|
||||
@@ -172,21 +183,4 @@ 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
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,7 +65,6 @@ public class AloneExam extends IdBaseEntity {
|
||||
private String ucode;
|
||||
|
||||
/**关联类型*/
|
||||
/**关联类型 新增关联类型14,代表成长路径图*/
|
||||
@Column(name = "ref_type", length = 30)
|
||||
private String refType;
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ExamTest extends BaseEntity {
|
||||
/**
|
||||
* 试卷的ID
|
||||
*/
|
||||
@Column(name = "paper_id",nullable = false,length=20)
|
||||
@Column(name = "paper_id",length=20)
|
||||
private String paperId;
|
||||
|
||||
/**
|
||||
@@ -173,19 +173,9 @@ public class ExamTest extends BaseEntity {
|
||||
|
||||
|
||||
/**启用的,上架*/
|
||||
@Column(name = "enabled", nullable = false, length = 1)
|
||||
@Column(name = "enabled", length = 1)
|
||||
private Boolean enabled;
|
||||
|
||||
@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,13 +5,11 @@ 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字段
|
||||
@@ -94,18 +92,10 @@ public interface IAloneExamService {
|
||||
|
||||
/**
|
||||
* 提交考试
|
||||
*
|
||||
* @param aea
|
||||
*/
|
||||
void submit(AloneExamAnswer aea, Integer scoreType);
|
||||
|
||||
/**
|
||||
* 同步考试成绩
|
||||
* @param aea
|
||||
* @param request
|
||||
*/
|
||||
void syncExamScoreToCourseSuite(AloneExamAnswer aea, HttpServletRequest request);
|
||||
|
||||
void submit(AloneExamAnswer aea,Integer scoreType);
|
||||
|
||||
/**
|
||||
* 更新答案
|
||||
* @param id
|
||||
@@ -166,7 +156,5 @@ public interface IAloneExamService {
|
||||
* @throws Exception
|
||||
*/
|
||||
PageList<TestUserDto> findTestUserAnswers(TestUserQuery params) throws Exception;
|
||||
|
||||
void examScoreBatchAdd(HttpServletRequest request, List<SaveExamScoreDto> saveExamScoreDtoList);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ 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 {
|
||||
/**
|
||||
* 分页查,状态,搜索,资源归属
|
||||
@@ -53,5 +51,4 @@ public interface IExamTestService {
|
||||
* */
|
||||
void enabled(String id,Boolean enabled);
|
||||
|
||||
void removeRel(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
package com.xboe.module.exam.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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;
|
||||
@@ -30,40 +20,31 @@ 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))
|
||||
@@ -72,8 +53,8 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void submit(AloneExamAnswer aea, Integer scoreType){
|
||||
@Transactional
|
||||
public void submit(AloneExamAnswer aea,Integer scoreType){
|
||||
//dao.update(aea);
|
||||
aea.setStatus(AloneExamAnswer.STATUS_FINISH);
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
@@ -121,27 +102,6 @@ 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
|
||||
@@ -467,86 +427,4 @@ 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,18 @@ public class ExamTestServiceImpl implements IExamTestService {
|
||||
|
||||
@Override
|
||||
public void update(ExamTest examTest) {
|
||||
examTestDao.update(examTest);
|
||||
if (examTest.getId() == null) {
|
||||
throw new IllegalArgumentException("ID must not be null");
|
||||
}
|
||||
String sql = "update boe_exam_test set arrange = "+ examTest.getArrange() +", deadline_time = '"+examTest.getDeadlineTime() +"' , " +
|
||||
"entrance_time = '"+examTest.getEntranceTime() +"' , paper_id = "+examTest.getPaperId() +",pass_line = "+examTest.getPassLine() +
|
||||
", percent_score = "+examTest.getPercentScore() +" ,publish_time = '"+examTest.getPublishTime()+"' , published = "+examTest.getPublished()+
|
||||
",random_count = "+examTest.getRandomCount()+" ,random_mode = "+examTest.getRandomMode()+",range_type = "+examTest.getRangeType() +
|
||||
",scoring_type = "+examTest.getScoringType() +",show_analysis="+examTest.getShowAnalysis() +",show_answer = "+examTest.getShowAnswer() +
|
||||
",test_duration = "+examTest.getTestDuration() +",test_name = '"+examTest.getTestName() +"',test_remark= '"+examTest.getTestRemark() +
|
||||
"',test_type= "+examTest.getTestType() +" ,test_up = '"+examTest.getTestUp() +"' ,test_front= '"+examTest.getTestFront() +
|
||||
"',times = '"+examTest.getTimes() +"' where id = "+examTest.getId()+"";
|
||||
examTestDao.sqlUpdate(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,10 +122,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,5 +94,5 @@ public interface IStudyService {
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
PageList<StudyCourseItem> findItemPage(int pageIndex,int pageSize,String contentId,String courseId,String name,Integer status);
|
||||
PageList<StudyCourseItem> findItemPage(int pageIndex, int pageSize, String contentId, String courseId, String name, Integer status);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.beans.KeyValue;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
import com.xboe.school.study.entity.StudySignup;
|
||||
|
||||
/**
|
||||
@@ -48,6 +49,13 @@ public interface IStudySignupService {
|
||||
* @param signup
|
||||
*/
|
||||
StudyCourse addSignup(StudySignup signup);
|
||||
|
||||
|
||||
/**
|
||||
* 管理员添加报名课件
|
||||
* @param signup
|
||||
*/
|
||||
StudyCourseItem addStudyCourseItem(StudySignup signup);
|
||||
|
||||
/**
|
||||
* 删除报名,只有未审核过的才可以删除
|
||||
|
||||
@@ -112,29 +112,34 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
||||
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_LAST){
|
||||
scItemDao.updateFieldById(exam.getStudyItemId(), "score",exam.getScore());
|
||||
scItemDao.updateFieldById(exam.getStudyItemId(), "progress",prog);
|
||||
}
|
||||
if(prog==100){
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "progress",100);
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "finish_time",LocalDateTime.now());
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "status",StudyCourseItem.STATUS_FINISH);
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "score",100.0f);
|
||||
if(exam.getScore()>=exam.getPassLine()){
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "progress",100);
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "finish_time",LocalDateTime.now());
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "status",StudyCourseItem.STATUS_FINISH);
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "score",exam.getScore());
|
||||
//scDao.updateFieldById(exam.getStudyId(), "last_score",100.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//1最高一次,用于最高一次的计算
|
||||
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_MAX) {
|
||||
Float f=(Float)dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()));
|
||||
Float f=(Float)dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()), FieldFilters.eq("courseId", exam.getCourseId()), FieldFilters.eq("studyId", exam.getStudyId()));
|
||||
scItemDao.updateFieldById(exam.getStudyItemId(), "score", f);
|
||||
scItemDao.updateFieldById(exam.getStudyItemId(), "status", f>=exam.getPassLine()?StudyCourseItem.STATUS_FINISH:StudyCourseItem.STATUS_STUDYING);
|
||||
scItemDao.updateFieldById(exam.getStudyItemId(), "progress",f>=exam.getPassLine()?100:f.intValue());
|
||||
|
||||
if(f>=exam.getPassLine()){
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "progress",100);
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "finish_time",LocalDateTime.now());
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "status",StudyCourseItem.STATUS_FINISH);
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "score",100.0f);
|
||||
scItemDao.updateFieldById(exam.getStudyId(), "score",exam.getScore());
|
||||
//scDao.updateFieldById(exam.getStudyId(), "last_score",100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
int totalContent = courseContentDao.getCount(exam.getCourseId());
|
||||
scDao.finishCheck(exam.getStudyId(),exam.getCourseId(),totalContent,token);
|
||||
scDao.updateFieldById(exam.getStudyId(), "last_score",exam.getScore());
|
||||
//执行完毕 清除redis记录
|
||||
// redisTemplate.delete(key);
|
||||
return "";
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.xboe.school.study.service.impl;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -8,7 +11,8 @@ import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.module.article.entity.Article;
|
||||
import com.xboe.module.interaction.entity.Shares;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -163,12 +167,10 @@ public class StudyServiceImpl implements IStudyService{
|
||||
|
||||
@Override
|
||||
public PageList<StudyCourseItem> findItemPage(int pageIndex, int pageSize, String contentId, String courseId,String name,Integer status) {
|
||||
|
||||
QueryBuilder query=QueryBuilder.from(StudyCourseItem.class);
|
||||
|
||||
QueryBuilder query = QueryBuilder.from(StudyCourseItem.class);
|
||||
query.setPageIndex(pageIndex);
|
||||
query.setPageSize(pageSize);
|
||||
|
||||
|
||||
OrderCondition oc=OrderCondition.desc("id");
|
||||
query.addOrder(oc);
|
||||
if(StringUtils.isNotBlank(contentId)) {
|
||||
@@ -177,19 +179,116 @@ public class StudyServiceImpl implements IStudyService{
|
||||
if(StringUtils.isNotBlank(courseId)) {
|
||||
query.addFilter(FieldFilters.eq("courseId",courseId));
|
||||
}
|
||||
|
||||
if(status!=null) {
|
||||
if(status==1) {
|
||||
query.addFilter(FieldFilters.eq("progress", 0));
|
||||
}else {
|
||||
query.addFilter(FieldFilters.eq("progress",100));
|
||||
}
|
||||
|
||||
}
|
||||
if(StringUtils.isNotBlank(name)) {
|
||||
query.addFilter(FieldFilters.eq("aname", name));
|
||||
}
|
||||
return scItemDao.findPage(query.builder());
|
||||
int pageIndex2 = (pageIndex-1)*10;
|
||||
if(status!=null) {
|
||||
if(status==3) {
|
||||
query.addFilter(FieldFilters.eq("status", 2));
|
||||
return scItemDao.findPage(query.builder());
|
||||
}else if(status==2){
|
||||
query.addFilter(FieldFilters.eq("status",9));
|
||||
return scItemDao.findPage(query.builder());
|
||||
}else if (status == 1) {
|
||||
String sql = "select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " +
|
||||
" left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" +
|
||||
" where bsc.course_id = '"+courseId+"' and bsc.id not in(" +
|
||||
" select item.study_id from boe_study_course_item item " +
|
||||
" where item.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by item.study_id" +
|
||||
" ) group by bsc.id limit "+ pageIndex2+","+ pageSize+";";
|
||||
|
||||
String sql2 = "select count(*) as total from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " +
|
||||
" left join boe_study_course_item item on bsc.course_id = item.course_id and bsc.id = item.study_id" +
|
||||
" where bsc.course_id = '"+courseId+"' and bsc.id not in(" +
|
||||
" select item.study_id from boe_study_course_item item " +
|
||||
" where item.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by item.study_id" +
|
||||
" ) group by bsc.id) as total";
|
||||
log.info("资源完成情况未开始sql"+sql);
|
||||
List<Object[]> list = scDao.sqlFindList(sql);
|
||||
log.info("资源完成情况人数"+list);
|
||||
int totalCount = scDao.sqlCount(sql2);
|
||||
List<StudyCourseItem> item = new ArrayList<>();
|
||||
for (Object[] objs : list) {
|
||||
StudyCourseItem sc = new StudyCourseItem();
|
||||
sc.setProgress(Integer.valueOf(objs[5].toString()));
|
||||
sc.setStatus(Integer.valueOf(objs[6].toString()));
|
||||
sc.setAname(objs[3].toString());
|
||||
item.add(sc);
|
||||
}
|
||||
log.info("资源完成情况人员"+item);
|
||||
PageList<StudyCourseItem> pageList = new PageList<>(item);
|
||||
pageList.setCount(totalCount);
|
||||
pageList.setPageSize(pageSize);
|
||||
pageList.setList(item);
|
||||
return pageList;
|
||||
}
|
||||
}
|
||||
// String sql = "select * from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.progress,item.status from boe_study_course bsc left join " +
|
||||
// "boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
||||
// "where bsc.`status` in (2,9) and bsc.course_id = '"+ courseId+"' group by bsc.id " +
|
||||
// " UNION ALL " +
|
||||
// " select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,0 as progress,1 as status from boe_study_course bsc " +
|
||||
// " LEFT JOIN boe_study_course_item item on item.course_id = bsc.course_id " +
|
||||
// " where bsc.course_id = '"+courseId+"' and bsc.id not in (" +
|
||||
// " select bsc.id from boe_study_course bsc " +
|
||||
// " left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
||||
// " where bsc.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by bsc.id" +
|
||||
// " )group by bsc.id) a group by a.id limit "+ pageIndex+","+ pageSize+";";
|
||||
|
||||
// String sql2 = "select count(*) from (select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.progress,item.status from boe_study_course bsc left join " +
|
||||
// "boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
||||
// "where bsc.`status` in (2,9) and bsc.course_id = '"+ courseId+"' group by bsc.id " +
|
||||
// " UNION ALL " +
|
||||
// " select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,0 as progress,1 as status from boe_study_course bsc " +
|
||||
// " LEFT JOIN boe_study_course_item item on item.course_id = bsc.course_id " +
|
||||
// " where bsc.course_id = '"+courseId+"' and bsc.id not in (" +
|
||||
// " select bsc.id from boe_study_course bsc " +
|
||||
// " left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
||||
// " where bsc.course_id = '" + courseId + "' and item.content_id = '"+ contentId+"' group by bsc.id" +
|
||||
// " )group by bsc.id) a group by a.id";
|
||||
|
||||
String sql = "select a.id, a.course_id, a.course_name, a.aname, " +
|
||||
"IFNULL(b.finish_time, '0') as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " +
|
||||
"from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "') a " +
|
||||
"left join " +
|
||||
"(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " +
|
||||
"from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
||||
"where bsc.course_id = '" + courseId + "' and item.content_id = '" + contentId + "' group by bsc.id) b " +
|
||||
"on a.course_id = b.course_id and a.id = b.id " +
|
||||
"group by a.id limit "+ pageIndex2+","+ pageSize+";";
|
||||
String sql2 = "select count(*) as total from (select a.id, a.course_id, a.course_name, a.aname, " +
|
||||
"IFNULL(b.finish_time, 0) as finish_time, IFNULL(b.progress, 0) as progress, IFNULL(b.status, 1) as status " +
|
||||
"from (select id, course_id, course_name, aname, 0, 1 from boe_study_course where course_id = '" + courseId + "') a " +
|
||||
"left join " +
|
||||
"(select bsc.id, bsc.course_id, bsc.course_name, bsc.aname, item.finish_time, item.progress, item.status " +
|
||||
"from boe_study_course bsc left join boe_study_course_item item on item.course_id = bsc.course_id and item.study_id = bsc.id " +
|
||||
"where bsc.course_id = '" + courseId + "' and item.content_id = '" + contentId + "' group by bsc.id) b " +
|
||||
"on a.course_id = b.course_id and a.id = b.id " +
|
||||
"group by a.id) as total";
|
||||
log.info("资源完成情况全部sql"+sql);
|
||||
List<Object[]> list = scDao.sqlFindList(sql);
|
||||
log.info("资源完成情况人数"+list);
|
||||
int totalCount = scDao.sqlCount(sql2);
|
||||
List<StudyCourseItem> item = new ArrayList<>();
|
||||
for (Object[] objs : list) {
|
||||
StudyCourseItem sc = new StudyCourseItem();
|
||||
if (!"0".equals(objs[4].toString())) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime finishTime = LocalDateTime.parse(objs[4].toString(), formatter);
|
||||
sc.setFinishTime(finishTime);
|
||||
}
|
||||
sc.setProgress(Integer.valueOf(objs[5].toString()));
|
||||
sc.setStatus(Integer.valueOf(objs[6].toString()));
|
||||
sc.setAname(objs[3].toString());
|
||||
item.add(sc);
|
||||
}
|
||||
log.info("资源完成情况人员"+item);
|
||||
PageList<StudyCourseItem> pageList = new PageList<>(item);
|
||||
pageList.setCount(totalCount);
|
||||
pageList.setPageSize(pageSize);
|
||||
pageList.setList(item);
|
||||
return pageList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,15 @@ import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.xboe.module.course.dao.CourseContentDao;
|
||||
import com.xboe.module.course.dto.CourseContentDto;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.school.study.dao.StudyCourseItemDao;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -39,7 +45,13 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
||||
|
||||
@Autowired
|
||||
StudyCourseDao studyCourseDao;
|
||||
|
||||
|
||||
@Autowired
|
||||
StudyCourseItemDao scItemDao;
|
||||
|
||||
@Autowired
|
||||
CourseContentDao contentDao;
|
||||
|
||||
@Autowired(required = false)
|
||||
ICourseStudySearch esSearch;
|
||||
|
||||
@@ -69,7 +81,6 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
||||
signupDao.save(signup);
|
||||
//添加到课程学习
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
|
||||
StudyCourse sc=new StudyCourse();
|
||||
sc.setAddTime(now);
|
||||
sc.setAid(signup.getAid());
|
||||
@@ -124,11 +135,40 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
||||
//courseDao.updateMultiFieldById(signup.getCourseId(),UpdateBuilder.create("studys", "studys+1",FieldUpdateType.EXPRESSION));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StudyCourseItem addStudyCourseItem(StudySignup signup) {
|
||||
String sql = "select id,course_id,content_name from boe_course_content where course_id = '"+signup.getCourseId()+"'";
|
||||
List<Object[]> courseContents = contentDao.sqlFindList(sql);
|
||||
if (!courseContents.isEmpty()) {
|
||||
log.info("查看在线课集合内容数据(共 {} 条记录)", courseContents.size());
|
||||
for (Object[] objs : courseContents){
|
||||
log.info("查看在线课内容数据: {}", objs[0].toString());
|
||||
// 使用toString()或自定义格式化字符串
|
||||
StudyCourseItem scitem = new StudyCourseItem();
|
||||
// 设置scitem的属性
|
||||
scitem.setAname(signup.getName());
|
||||
scitem.setAid(signup.getAid());
|
||||
scitem.setCourseId(signup.getCourseId());
|
||||
scitem.setProgress(0);
|
||||
scitem.setScore(0f);
|
||||
scitem.setStatus(1);
|
||||
scitem.setContentId(objs[0].toString());
|
||||
scitem.setStudyId(signup.getStudyId());
|
||||
// 如果需要,可以取消注释以下行来设置contentName
|
||||
// scitem.setContentName(c.getContentName());
|
||||
scItemDao.save(scitem);
|
||||
}
|
||||
} else {
|
||||
log.info("没有找到在线课内容数据。");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void addList(List<StudySignup> list) {
|
||||
//用于管理员添加报名
|
||||
for(StudySignup ss : list) {
|
||||
addSignup(ss);
|
||||
// addStudyCourseItem(ss);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +176,6 @@ public class StudySignupServiceImpl implements IStudySignupService{
|
||||
public void audit(String id, String aid, String user, boolean pass, String remark) {
|
||||
if(pass) {
|
||||
StudySignup signup =signupDao.get(id);
|
||||
|
||||
//是否需要检查是否已报名
|
||||
StudyCourse sc=new StudyCourse();
|
||||
sc.setAddTime(LocalDateTime.now());
|
||||
|
||||
@@ -71,9 +71,7 @@ audience.getOrgUsers=${boe.domain}/userbasic/user/getOrgUsers
|
||||
infrasApi.dict=${boe.domain}/infrasApi/dict/list
|
||||
#获取非报名课id
|
||||
manageApi.stu.offcourse=${boe.domain}/manageApi/stu/offcourse/getOffCourseId
|
||||
manageApi.editExam=${boe.domain}/manageApi/admin/project/editExam
|
||||
#获取离职教师id
|
||||
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
|
||||
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
|
||||
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
||||
Reference in New Issue
Block a user