mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 17:36:47 +08:00
szx-1293 课程表进度未更新监控
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xboe.module.course.dao;
|
||||||
|
|
||||||
|
import com.xboe.core.orm.BaseDao;
|
||||||
|
import com.xboe.module.course.entity.ThreadLog;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public class ThreadLogDao extends BaseDao<ThreadLog> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package com.xboe.module.course.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.xboe.core.SysConstant;
|
||||||
|
import com.xboe.core.orm.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线程日志表实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Table(name = SysConstant.TABLE_PRE + "thread_log")
|
||||||
|
public class ThreadLog extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "id", columnDefinition = "BIGINT UNSIGNED COMMENT '主键'")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统/子系统标识
|
||||||
|
*/
|
||||||
|
@Column(name = "system_name", nullable = false, length = 64)
|
||||||
|
private String systemName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能模块
|
||||||
|
*/
|
||||||
|
@Column(name = "module_name", nullable = false, length = 64)
|
||||||
|
private String moduleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 具体动作/事件
|
||||||
|
*/
|
||||||
|
@Column(name = "action_name", nullable = false, length = 64)
|
||||||
|
private String actionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志级别(INFO/WARN/ERROR/DEBUG等)
|
||||||
|
*/
|
||||||
|
@Column(name = "level", nullable = false, length = 16)
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志正文/描述
|
||||||
|
*/
|
||||||
|
@Column(name = "content", columnDefinition = "TEXT COMMENT '日志正文/描述'")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 线程名称
|
||||||
|
*/
|
||||||
|
@Column(name = "thread_name", length = 64)
|
||||||
|
private String threadName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结构化扩展信息(JSON)
|
||||||
|
* 注:用String接收JSON字符串,如需反序列化可自行处理(如使用ObjectMapper转换为Map/自定义DTO)
|
||||||
|
*/
|
||||||
|
@Column(name = "extra_data", columnDefinition = "JSON COMMENT '结构化扩展信息(JSON)'")
|
||||||
|
private String extraData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@Column(name = "remark", length = 255)
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Column(name = "create_time", nullable = false)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人ID
|
||||||
|
*/
|
||||||
|
@Column(name = "create_id", columnDefinition = "BIGINT COMMENT '创建人ID'")
|
||||||
|
private Long createId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人姓名
|
||||||
|
*/
|
||||||
|
@Column(name = "create_name", length = 128)
|
||||||
|
private String createName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Column(name = "update_time", nullable = false)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人ID
|
||||||
|
*/
|
||||||
|
@Column(name = "update_id", columnDefinition = "BIGINT COMMENT '更新人ID'")
|
||||||
|
private Long updateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人姓名
|
||||||
|
*/
|
||||||
|
@Column(name = "update_name", length = 128)
|
||||||
|
private String updateName;
|
||||||
|
}
|
||||||
@@ -4,8 +4,11 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
import com.xboe.constants.CacheName;
|
import com.xboe.constants.CacheName;
|
||||||
|
import com.xboe.module.course.dao.ThreadLogDao;
|
||||||
|
import com.xboe.school.study.dto.StudyContentDto;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -32,7 +35,8 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
StudyCourseItemDao scItemDao;
|
StudyCourseItemDao scItemDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
StringRedisTemplate redisTemplate;
|
StringRedisTemplate redisTemplate;
|
||||||
|
@Autowired
|
||||||
|
private ThreadLogDao threadLogDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ThirdApi thirdApi;
|
private ThirdApi thirdApi;
|
||||||
@@ -45,6 +49,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
public void finishCheck(String studyId,String courseId,Integer total,String token){
|
public void finishCheck(String studyId,String courseId,Integer total,String token){
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(studyId + "_" + courseId + "_" + total))){
|
if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(studyId + "_" + courseId + "_" + total))){
|
||||||
|
saveThreadLog(studyId, courseId, total, token);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +78,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
UpdateBuilder.create("finishTime",now),
|
UpdateBuilder.create("finishTime",now),
|
||||||
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
|
||||||
redisTemplate.opsForValue().set(studyId + "_" + courseId + "_" + total, "100", 24, TimeUnit.HOURS);
|
redisTemplate.opsForValue().set(studyId + "_" + courseId + "_" + total, "100", 24, TimeUnit.HOURS);
|
||||||
|
saveThreadLog(studyId, courseId, total, token);
|
||||||
}else {
|
}else {
|
||||||
super.updateMultiFieldById(studyId,
|
super.updateMultiFieldById(studyId,
|
||||||
UpdateBuilder.create("progress",percent),
|
UpdateBuilder.create("progress",percent),
|
||||||
@@ -85,6 +91,40 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
|||||||
log.info("在线课学习记录"+allUserList);
|
log.info("在线课学习记录"+allUserList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveThreadLog(String studyId,String courseId,Integer total,String token) {
|
||||||
|
try {
|
||||||
|
JSONObject extraData = new JSONObject();
|
||||||
|
extraData.put("studyId", studyId);
|
||||||
|
extraData.put("courseId", courseId);
|
||||||
|
extraData.put("total", total);
|
||||||
|
extraData.put("token", token);
|
||||||
|
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
String threadName = Thread.currentThread().getName();
|
||||||
|
|
||||||
|
String sql = "INSERT INTO boe_thread_log (system_name,module_name,action_name,level,content,thread_name,extra_data,remark,create_time,create_id,create_name,update_time,update_id,update_name) "
|
||||||
|
+ "VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14)";
|
||||||
|
|
||||||
|
threadLogDao.sqlUpdate(sql,
|
||||||
|
"学习",
|
||||||
|
"学习进度更新",
|
||||||
|
"更新StudyCourse进度完成",
|
||||||
|
"info",
|
||||||
|
null,
|
||||||
|
threadName,
|
||||||
|
extraData.toJSONString(),
|
||||||
|
null,
|
||||||
|
now,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
now,
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("保存线程日志失败", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void finishCheck1(String studyId,String courseId,Integer total){
|
public void finishCheck1(String studyId,String courseId,Integer total){
|
||||||
LocalDateTime now=LocalDateTime.now();
|
LocalDateTime now=LocalDateTime.now();
|
||||||
//已完成的内容
|
//已完成的内容
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
import com.xboe.module.course.dao.ThreadLogDao;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.xboe.common.OrderCondition;
|
import com.xboe.common.OrderCondition;
|
||||||
import com.xboe.common.PageList;
|
import com.xboe.common.PageList;
|
||||||
import com.xboe.core.orm.FieldFilters;
|
import com.xboe.core.orm.FieldFilters;
|
||||||
@@ -52,6 +54,8 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
@Autowired
|
@Autowired
|
||||||
StringRedisTemplate redisTemplate;
|
StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThreadLogDao threadLogDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StudyCourseItem checkHas(String studyId,String contentId) {
|
public StudyCourseItem checkHas(String studyId,String contentId) {
|
||||||
@@ -82,6 +86,7 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
sci.setStudyDuration(0);
|
sci.setStudyDuration(0);
|
||||||
sci.setCourseId(dto.getCourseId());
|
sci.setCourseId(dto.getCourseId());
|
||||||
sci.setCsectionId(dto.getCsectionId());
|
sci.setCsectionId(dto.getCsectionId());
|
||||||
|
saveThreadLog(dto);
|
||||||
}
|
}
|
||||||
//进度状态
|
//进度状态
|
||||||
if(dto.getProgress()==null) {
|
if(dto.getProgress()==null) {
|
||||||
@@ -494,4 +499,51 @@ public class StudyServiceImpl implements IStudyService{
|
|||||||
scDao.finishCheck(studyId,courseId,cnum,token);
|
scDao.finishCheck(studyId,courseId,cnum,token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveThreadLog(StudyContentDto dto) {
|
||||||
|
try {
|
||||||
|
JSONObject extraData = new JSONObject();
|
||||||
|
extraData.put("studyId", dto.getStudyId());
|
||||||
|
extraData.put("contentId", dto.getContentId());
|
||||||
|
extraData.put("aid", dto.getAid());
|
||||||
|
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
Long creatorId = parseLong(dto.getAid());
|
||||||
|
String creatorName = dto.getAname();
|
||||||
|
String threadName = Thread.currentThread().getName();
|
||||||
|
|
||||||
|
String sql = "INSERT INTO boe_thread_log (system_name,module_name,action_name,level,content,thread_name,extra_data,remark,create_time,create_id,create_name,update_time,update_id,update_name) "
|
||||||
|
+ "VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14)";
|
||||||
|
|
||||||
|
threadLogDao.sqlUpdate(sql,
|
||||||
|
"学习",
|
||||||
|
"学习进度更新",
|
||||||
|
"新增StudyCourseItem",
|
||||||
|
"info",
|
||||||
|
null,
|
||||||
|
threadName,
|
||||||
|
extraData.toJSONString(),
|
||||||
|
null,
|
||||||
|
now,
|
||||||
|
creatorId,
|
||||||
|
creatorName,
|
||||||
|
now,
|
||||||
|
creatorId,
|
||||||
|
creatorName);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.error("保存线程日志失败 studyId={}, contentId={}, aid={}", dto.getStudyId(), dto.getContentId(), dto.getAid(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long parseLong(String value) {
|
||||||
|
if(StringUtils.isBlank(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Long.valueOf(value);
|
||||||
|
}catch (NumberFormatException ex){
|
||||||
|
log.warn("无法解析为数字的aid: {}", value);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user