Compare commits

..

21 Commits

Author SHA1 Message Date
yang
897a44e2c3 成长路径图,解除绑定接口去除 2024-07-17 10:20:23 +08:00
yang
a019726181 成长路径图,内部考试引用关系,以及导入bug修复 2024-07-15 10:21:32 +08:00
yang
3b34cc1bde 成长路径图,考试添加关联字段 2024-07-11 16:33:22 +08:00
yang
be18e35583 成长路径图,考试导入完成状态去除 2024-07-11 11:07:26 +08:00
yang
bd25fc1d1a 成长路径图,考试同步,限制事务范围 2024-07-10 16:55:17 +08:00
yang
91b0b899b0 成长路径图,考试同步,限制事务范围 2024-07-10 16:28:42 +08:00
yang
983313e845 成长路径图,考试同步 2024-07-10 14:25:18 +08:00
yang
f4c1bd7eed 成长路径图,考试次数 2024-07-10 12:49:19 +08:00
yang
0ac6622526 成长路径图,去除导入同步 2024-07-10 08:51:24 +08:00
yang
9a83f64e38 成长路径图,导入添加同步信息 2024-07-09 13:50:55 +08:00
yang
26a2a8e709 成长路径图,bug修复 2024-07-08 16:06:42 +08:00
yang
170dc45c64 成长路径图,导入考试去除属性 2024-07-08 14:49:54 +08:00
yang
5594e07264 成长路径图,考试计数 2024-07-08 14:49:31 +08:00
yang
13b5e6ab4c 成长路径图,考试实时同步,去除异常 2024-07-08 11:35:47 +08:00
yang
e144fde444 成长路径图,考试实时同步 2024-07-08 11:12:57 +08:00
yang
a4f260b99a 成长路径图,考试 2024-07-03 09:01:53 +08:00
yang
de7d26f447 成长路径图,考试绑定 2024-07-01 11:14:04 +08:00
yang
e2e0aeb9cb 成长路径图,考试绑定 2024-07-01 10:36:06 +08:00
yang
bcdc784e7d 成长路径图,保存考试信息 2024-06-23 22:03:07 +08:00
yang
7c4a6feb78 成长路径图,保存考试信息 2024-06-23 17:56:03 +08:00
yang
aa245e52c6 成长路径图,保存考试信息 2024-06-22 11:29:22 +08:00
36 changed files with 2006 additions and 2086 deletions

View File

@@ -84,6 +84,7 @@
<artifactId>xboe-module-es</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId>

View File

@@ -4,21 +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.ExamTest;
import com.xboe.module.exam.entity.AloneExam;
import com.xboe.school.study.entity.StudyCourse;
import com.xboe.system.user.dao.UserDao;
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.stereotype.Service;
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;
@@ -61,8 +62,12 @@ public class ThirdApi {
@Value("${coursesuilt.getStudyStatus}")
private String getStudyStatus;
@Value("${manageApi.editExam}")
private String editExam;
@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
@@ -207,14 +212,6 @@ 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().
@@ -226,10 +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();
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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));
}
}

View File

@@ -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;
}
}

View File

@@ -133,6 +133,4 @@ public interface CacheName {
* 字典缓存key
* */
String KEY_DICT="dict";
String STUDY_KEY = "StudyKey:";
}

View File

@@ -17,7 +17,5 @@ public class UserOrgIds {
private Map<String,Boolean> permissions=new HashMap<String,Boolean>();
private List<String> ids;
//hrbp只读权限
private List<String> readIds;
}

View File

@@ -229,10 +229,8 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
public UserOrgIds getOrgIds() {
UserOrgIds uids=new UserOrgIds();
List<String> orgIds = new ArrayList<>();
List<String> readIds = new ArrayList<>();
uids.setIds(orgIds);
uids.setReadIds(readIds);
String token = TokenProxy.getToken(request);
String type="application/json";
String[] headers=new String[] {"token",token,"Content-Type",type};
@@ -283,8 +281,7 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
while (elements.hasNext()){
String oid=elements.next().asText();
if(!orgSetIds.contains(oid)) {
// orgIds.add(oid);
readIds.add(oid);
orgIds.add(oid);
}
}
}

View File

@@ -1,7 +1,11 @@
package com.xboe.module.course.api;
import java.io.OutputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -130,6 +134,7 @@ public class CourseManageApi extends ApiBaseController{
}else {
dto.setIsSystemAdmin(false);
}
String ids="";
if(userOrgIds.getIds()!=null && !userOrgIds.getIds().isEmpty())
{
@@ -137,14 +142,12 @@ public class CourseManageApi extends ApiBaseController{
}
//log.info("获取到的用户的组织机构权限ids",ids);
String aid=getCurrent().getAccountId();
// String aid="1706272694871445506";
//如果前端查询当前人的,这里去掉
if(StringUtils.isNotBlank(dto.getAid())) {
dto.setAid(null);
}
dto.setOrgAid(aid);
dto.setOrgIds(ids);
dto.setReadIds(userOrgIds.getReadIds());
PageList<Course> coursePageList = courseService.findPage(pager.getPageIndex(), pager.getPageSize(),dto);
return success(coursePageList);
}catch(Exception e) {

View File

@@ -1,13 +1,10 @@
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> {
@@ -23,5 +20,4 @@ public class CourseContentDao extends BaseDao<CourseContent> {
int count=count(hql, courseId);
return count;
}
}

View File

@@ -2,8 +2,6 @@ package com.xboe.module.course.dto;
import lombok.Data;
import java.util.List;
/**
* 课程查询的条件对象
*/
@@ -104,9 +102,6 @@ public class CourseQueryDto {
* */
private String orgIds;
//hrpb只读
private List<String> readIds;
/**用户权限的查询*/
private String orgAid;
@@ -115,11 +110,6 @@ public class CourseQueryDto {
*/
private Boolean isSystemAdmin;
/**
* 是否是新建在线可
*/
private Boolean isCreateCourse;
private Boolean visible;
private String refId;
@@ -139,5 +129,4 @@ public class CourseQueryDto {
* 登录人id
*/
private String userId;
}

View File

@@ -370,9 +370,6 @@ public class Course extends BaseEntity {
@Column(name = "ref_type",length=32,columnDefinition="varchar(32) comment '反向关联的类型'")
private String refType;
@Transient
private Boolean isPermission=true;
@Transient
private String orgName;

View File

@@ -83,13 +83,8 @@ public class CourseContent extends BaseEntity {
* */
@Column(name = "duration")
private Integer duration;
/**
* 视频播放进度
* */
@Column(name = "progress_video")
private Float progressVideo;
/**用于学习时的状态显示,非存储字段*/
@Transient
private Integer status;
@@ -105,21 +100,6 @@ 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 +
'}';
}
}

View File

@@ -82,7 +82,4 @@ public interface ICourseContentService{
* @return
*/
CourseAssess getAssess(String ccid);
void updateProcessVideo(String contentId, String courseId, Float processVideo);
}

View File

@@ -214,12 +214,6 @@ 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);

View File

@@ -1,7 +1,5 @@
package com.xboe.module.course.service.impl;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import javax.annotation.Resource;
@@ -143,17 +141,6 @@ public class CourseContentServiceImpl implements ICourseContentService {
return assess;
}
@Override
@Transactional
public void updateProcessVideo(String id, String courseId, Float progressVideo) {
// 处理 processVideo 为 null 的情况
if (progressVideo == null) {
progressVideo = 0.00f;
}
String sql = "UPDATE boe_course_content SET progress_video = "+ progressVideo+" WHERE id = "+ id+" AND course_id = "+ courseId+" ";
ccDao.sqlUpdate(sql);
}
@Override
@Transactional
public void updateName(String id, String name) {

View File

@@ -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("导入成功");
}
}

View File

@@ -3,14 +3,10 @@ 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.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 org.springframework.web.bind.annotation.*;
import com.xboe.common.PageList;
import com.xboe.common.Pagination;
@@ -23,6 +19,8 @@ import com.xboe.module.exam.service.IExamTestService;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
* 考试
* */
@@ -33,8 +31,10 @@ public class ExamTestApi extends ApiBaseController {
@Resource
private IExamTestService examTestService;
@Resource
ThirdApi thirdApi;
private ThirdApi thirdApi;
/**
*查询考试,分页,搜索,资源归属,状态
**/
@@ -82,33 +82,16 @@ public class ExamTestApi extends ApiBaseController {
* */
@PostMapping("update")
@AutoLog(module = "考试",action = "修改考试",info = "修改考试")
public JsonResponse<ExamTest> update(@RequestBody ExamTest examTest, HttpServletRequest request){
public JsonResponse<ExamTest> update(@RequestBody ExamTest examTest){
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());
}
}
/**、
@@ -133,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);
@@ -183,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());
}
}
}

View File

@@ -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;
}

View File

@@ -65,6 +65,7 @@ public class AloneExam extends IdBaseEntity {
private String ucode;
/**关联类型*/
/**关联类型 新增关联类型14代表成长路径图*/
@Column(name = "ref_type", length = 30)
private String refType;

View File

@@ -28,7 +28,7 @@ public class ExamTest extends BaseEntity {
/**
* 考试名称
* */
@Column(name = "test_name",length = 50)
@Column(name = "test_name",nullable = false,length = 50)
private String testName;
/**
@@ -46,7 +46,7 @@ public class ExamTest extends BaseEntity {
/**
* 考试时长 分钟
* */
@Column(name = "test_duration")
@Column(name = "test_duration",nullable = false)
private Integer testDuration;
/**
* 显示解析
@@ -101,19 +101,19 @@ public class ExamTest extends BaseEntity {
/**
* 试卷的ID
*/
@Column(name = "paper_id",length=20)
@Column(name = "paper_id",nullable = false,length=20)
private String paperId;
/**
* 考试的类型
* */
@Column(name = "test_type")
@Column(name = "test_type",nullable = false)
private Integer testType;
/**
* 发布状态 ,是否已发布
*/
@Column(name = "published",length = 1)
@Column(name = "published",length = 1,nullable = false)
private Boolean published;
/**
* 发布时间
@@ -154,7 +154,7 @@ public class ExamTest extends BaseEntity {
/**
* 范围1表独立使用2表课程内部
* */
@Column(name = "range_type")
@Column(name = "range_type",nullable = false)
private Integer rangeType;
/**
@@ -173,9 +173,19 @@ public class ExamTest extends BaseEntity {
/**启用的,上架*/
@Column(name = "enabled", length = 1)
@Column(name = "enabled", nullable = false, 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;
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}
});
}
}

View File

@@ -70,18 +70,7 @@ public class ExamTestServiceImpl implements IExamTestService {
@Override
public void update(ExamTest 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);
examTestDao.update(examTest);
}
@Override
@@ -95,7 +84,7 @@ public class ExamTestServiceImpl implements IExamTestService {
@Override
public Boolean has(String paperId) {
ExamTest et=examTestDao.findOne(FieldFilters.eq("paperId", paperId),FieldFilters.eq("deleted", false));
ExamTest et=examTestDao.findOne(FieldFilters.eq("paperId", paperId));
//String etId= (String)examTestDao.findField("id", FieldFilters.eq("paperId", paperId));
if(et==null){
return true;
@@ -122,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);
}
}

View File

@@ -3,12 +3,15 @@ package com.xboe.school.study.api;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
import cn.hutool.core.util.ArrayUtil;
import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName;
import com.xboe.api.vo.*;
import com.xboe.module.course.vo.TeacherVo;
import com.xboe.module.usergroup.entity.UserGroupItem;
import com.xboe.module.usergroup.service.IUserGroupService;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -92,6 +95,7 @@ public class StudyCourseApi extends ApiBaseController{
@Autowired
StringRedisTemplate redisTemplate;
/**
* 用于查询课程的学习记录
* @param pager
@@ -283,7 +287,11 @@ public class StudyCourseApi extends ApiBaseController{
}
/**
* 记录学习信息,在学习每个资源时都要记录.前端用户打开课程资源按规则调用带着课程及学习信息调用此接口。
* @param
* @return 返回学习条目的id
*/
@PostMapping("/study")
public JsonResponse<String> study(@RequestBody StudyContentDto sci, HttpServletRequest request){
@@ -313,34 +321,20 @@ public class StudyCourseApi extends ApiBaseController{
if (StringUtils.isEmpty(token)) {
token = request.getHeader("token");
}
//检查是否已存在
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
if(item!=null) {
String studyKey = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + item.getCourseId()+":"+cuser.getAccountId()+":"+item.getContentId();
String studyKey2 = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + sci.getCourseId()+":"+cuser.getAccountId()+":"+sci.getContentId();
redisTemplate.opsForValue().set(studyKey,
String.valueOf(item.getProgress()), 2, TimeUnit.HOURS);
String progressStr = redisTemplate.opsForValue().get(studyKey2);
if (progressStr != null && !progressStr.isEmpty()) {
// 尝试将 Redis 中的字符串转换为整数
int redisProgress = Integer.parseInt(progressStr);
// 假设 item.getProgress() 返回的是 int 类型
int sciProgress = sci.getProgress();
if (redisProgress < sciProgress && redisProgress < 100) {
// 执行一些操作
// if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
// }
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
}
//如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
}
//追加学习时长
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
log.info("在线课学习记录"+allUserList);
return success(item.getId());
//如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况
}
if(StringUtils.isBlank(sci.getCourseId())){
return error("无课程信息");
}
@@ -535,7 +529,7 @@ public class StudyCourseApi extends ApiBaseController{
* @return
*/
@PostMapping("/study-video-time")
public JsonResponse<Boolean> study(String itemId,Integer videoTime,String contentId , String courseId,Float progressVideo){
public JsonResponse<Boolean> study(String studyId,String itemId,Integer videoTime){
if(StringUtils.isBlank(itemId)){
return error("参数错误");
@@ -545,10 +539,7 @@ public class StudyCourseApi extends ApiBaseController{
}
//检查是否已存在
try {
studyService.updateLastTime(itemId,videoTime, getCurrent().getAccountId());
if (contentId != null && courseId != null && progressVideo != null){
contentService.updateProcessVideo(contentId, courseId, progressVideo);
}
studyService.updateLastTime(itemId,videoTime,getCurrent().getAccountId());
return success(true);
}catch(Exception e) {
log.error("记录最后学习时间错误",e);

View File

@@ -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);
}

View File

@@ -6,7 +6,6 @@ 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;
/**
@@ -49,13 +48,6 @@ public interface IStudySignupService {
* @param signup
*/
StudyCourse addSignup(StudySignup signup);
/**
* 管理员添加报名课件
* @param signup
*/
StudyCourseItem addStudyCourseItem(StudySignup signup);
/**
* 删除报名,只有未审核过的才可以删除

View File

@@ -44,7 +44,7 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
LocalDateTime ldt=LocalDateTime.now();
sci.setStudyId(assess.getStudyId());
sci.setContentId(assess.getContentId());
sci.setContentName("评估");
//sci.setContentName(homework.getContentName());
sci.setCourseId(assess.getCourseId());
//sci.setCsectionId(homework.getCsectionId());
sci.setProgress(100);//直接设置为学习完成

View File

@@ -82,7 +82,7 @@ public class StudyExamServiceImpl implements IStudyExamService{
LocalDateTime ldt=LocalDateTime.now();
sci.setStudyId(exam.getStudyId());
sci.setContentId(exam.getContentId());
sci.setContentName("考试");
//sci.setContentName(homework.getContentName());
sci.setCourseId(exam.getCourseId());
//sci.setCsectionId(homework.getCsectionId());
sci.setProgress(prog);//直接设置为学习完成
@@ -112,34 +112,29 @@ 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(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);
}
}
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);
}
}
//1最高一次,用于最高一次的计算
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_MAX) {
Float f=(Float)dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()), FieldFilters.eq("courseId", exam.getCourseId()), FieldFilters.eq("studyId", exam.getStudyId()));
Float f=(Float)dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()));
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",exam.getScore());
//scDao.updateFieldById(exam.getStudyId(), "last_score",100.0f);
scItemDao.updateFieldById(exam.getStudyId(), "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 "";

View File

@@ -46,7 +46,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
LocalDateTime ldt=LocalDateTime.now();
sci.setStudyId(homework.getStudyId());
sci.setContentId(homework.getContentId());
sci.setContentName(homework.getHwName());
//sci.setContentName(homework.getContentName());
sci.setCourseId(homework.getCourseId());
//sci.setCsectionId(homework.getCsectionId());
sci.setProgress(100);//直接设置为学习完成
@@ -67,7 +67,7 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
//只是保留一条作业记录,不再保存多条记录了
//dao.save(homework);
//设置id。然后进行悠
homework.setId(homework.getStudyItemId());
homework.setId(obj.toString());
dao.update(homework);
}
}

View File

@@ -1,9 +1,6 @@
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;
@@ -11,8 +8,7 @@ import java.util.Map;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import com.xboe.module.article.entity.Article;
import com.xboe.module.interaction.entity.Shares;
import com.xboe.api.ThirdApi;
import com.xboe.school.study.entity.StudyCourse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -98,12 +94,8 @@ public class StudyServiceImpl implements IStudyService{
//sci.setProgress(100);//直接设置为学习完成
sci.setLastTime(ldt);
scItemDao.saveOrUpdate(sci);
if (sci.getId() != null){
dto.setStudyItemId(sci.getId());
}else {
log.info("学习记录插入失败"+sci.getId());
throw new IllegalArgumentException("学习记录插入失败");
}
dto.setStudyItemId(sci.getId());
//检查是否全部学习完成
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal(),token);
@@ -171,10 +163,12 @@ 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)) {
@@ -183,92 +177,19 @@ 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));
}
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.aname like '%"+name+"%' 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+"' and item.aname like '%"+name+"%' 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.aname like '%"+name+"%' 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+"' and item.aname like '%"+name+"%' 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 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 + "' and aname like '%"+name+"%') 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 + "' and item.aname like '%"+name+"%' 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 + "' and aname like '%"+name+"%') 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 + "' and item.aname like '%"+name+"%' 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;
return scItemDao.findPage(query.builder());
}

View File

@@ -4,15 +4,9 @@ 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;
@@ -45,13 +39,7 @@ public class StudySignupServiceImpl implements IStudySignupService{
@Autowired
StudyCourseDao studyCourseDao;
@Autowired
StudyCourseItemDao scItemDao;
@Autowired
CourseContentDao contentDao;
@Autowired(required = false)
ICourseStudySearch esSearch;
@@ -81,6 +69,7 @@ public class StudySignupServiceImpl implements IStudySignupService{
signupDao.save(signup);
//添加到课程学习
LocalDateTime now=LocalDateTime.now();
StudyCourse sc=new StudyCourse();
sc.setAddTime(now);
sc.setAid(signup.getAid());
@@ -135,40 +124,11 @@ 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);
}
}
@@ -176,6 +136,7 @@ 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());

View File

@@ -71,7 +71,9 @@ 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
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