mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-08 10:26:48 +08:00
Merge branch 'third'
This commit is contained in:
@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.module.scorm.cam.load.SCORMPackageManager;
|
||||
import com.xboe.module.scorm.cam.load.ZipUtils;
|
||||
import com.xboe.module.scorm.cam.model.ContentPackage;
|
||||
import com.xboe.module.scorm.cam.model.Item;
|
||||
import com.xboe.module.scorm.cam.model.Manifest;
|
||||
@@ -23,7 +24,13 @@ public class SCORMParser {
|
||||
|
||||
public String parserToJson(String path) throws Exception {
|
||||
// System.out.println("test");
|
||||
ContentPackage cp=SCORMPackageManager.getInstance().loadSCORMContentPackageFromZipFile("1", path);
|
||||
ContentPackage cp=null;
|
||||
if(ZipUtils.isEndWithZip(path)) {
|
||||
cp=SCORMPackageManager.getInstance().loadSCORMContentPackageFromZipFile("1", path);
|
||||
}else {
|
||||
cp=SCORMPackageManager.getInstance().readSCORMContentPackage("1", path);
|
||||
}
|
||||
//ContentPackage cp=SCORMPackageManager.getInstance().readSCORMContentPackage("1", path);
|
||||
Manifest manifest= cp.getManifest();
|
||||
// System.out.println(cp.getManifest().getIdentifier());
|
||||
// System.out.println(cp.getContent());
|
||||
@@ -81,8 +88,14 @@ public class SCORMParser {
|
||||
}
|
||||
|
||||
//scorm的版本
|
||||
data.setSchema(manifest.getMetadata().getSchema());
|
||||
data.setVersion(manifest.getMetadata().getSchemaVersion());
|
||||
if(manifest.getMetadata()==null) {
|
||||
data.setSchema("ADL SCORM");
|
||||
data.setVersion("1.2");
|
||||
}else {
|
||||
data.setSchema(manifest.getMetadata().getSchema());
|
||||
data.setVersion(manifest.getMetadata().getSchemaVersion());
|
||||
}
|
||||
|
||||
data.setScoItems(scoItems);//sco共有多少个
|
||||
if(scoItems.size()>0 && scoItems.get(0).getScoUrl()!=null) {
|
||||
data.setIndex(scoItems.get(0).getScoUrl());//打开播放时进入的第一个sco
|
||||
@@ -108,7 +121,7 @@ public class SCORMParser {
|
||||
// public static void main(String[] args) {
|
||||
// SCORMParser parser=new SCORMParser();
|
||||
// //String path1="E:/Projects/BOEU/scorm/file/ContentPackagingOneFilePerSCO_SCORM12.zip";
|
||||
// String path1="E:/Projects/BOEU/scorm/file/7a462dbee222ba62810191d2f512576e.zip";
|
||||
// String path1="E:/Projects/BOEU/scorm/file/7a462dbee222ba62810191d2f512576e";
|
||||
// try {
|
||||
// String json= parser.parserToJson(path1);
|
||||
// System.out.println(json);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.xboe.module.scorm.cam.model.Resource;
|
||||
import com.xboe.module.scorm.common.LMSPersistDriverManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -112,6 +113,50 @@ public class SCORMPackageManager {
|
||||
|
||||
return contentPackage;
|
||||
}
|
||||
|
||||
public ContentPackage readSCORMContentPackage(String lmsContentPackageID, String packagePath) {
|
||||
if (StringUtils.isBlank(packagePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// step 1: uncompress
|
||||
File f=new File(packagePath);
|
||||
if(!f.exists()) {
|
||||
log.error( packagePath+ " is not exists");
|
||||
return null;
|
||||
}
|
||||
if(!f.isDirectory()) {
|
||||
log.error( packagePath+ " is not directory");
|
||||
return null;
|
||||
}
|
||||
|
||||
String saveDir=packagePath;
|
||||
// step 2: validate all xml file in saveDir
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
if (!XmlSchemaValidator.validateAllXmlFileWithSchemaFileInPath(saveDir)) {
|
||||
log.error("validate xml schema error.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// step 3: 读取imsmanifest.xml,生成ContentPackage
|
||||
ContentPackage contentPackage = new ContentPackageGenerator().generateContentPackageFromFile(saveDir);
|
||||
if (contentPackage == null) {
|
||||
log.error("generate content package error.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// step 4: 验证ContentPackage
|
||||
// ContentPackageValidator validator = new ContentPackageValidator(false);
|
||||
// boolean validateResult = validator.validate(contentPackage, saveDir);
|
||||
// if (!validateResult) {
|
||||
// log.error("validate content package error: " + validator.getErrors());
|
||||
// return null;
|
||||
// }
|
||||
|
||||
contentPackageMap.put(lmsContentPackageID, contentPackage);
|
||||
|
||||
return contentPackage;
|
||||
}
|
||||
|
||||
public int contentPackageCount() {
|
||||
return contentPackageMap.size();
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xboe.data.dto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserOrgIds {
|
||||
|
||||
/**
|
||||
* 是否是超级管理员
|
||||
*/
|
||||
public static final String IsSystemAdminKey="isSystemAdmin";
|
||||
|
||||
private Map<String,Boolean> permissions=new HashMap<String,Boolean>();
|
||||
|
||||
private List<String> ids;
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.dto.UserData;
|
||||
import com.xboe.data.dto.UserOrgIds;
|
||||
|
||||
public interface IOutSideDataService {
|
||||
|
||||
@@ -22,6 +23,6 @@ public interface IOutSideDataService {
|
||||
/**
|
||||
* 获取用户有权限的机构id
|
||||
* */
|
||||
List<String> getOrgIds();
|
||||
UserOrgIds getOrgIds();
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.xboe.core.api.TokenProxy;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.data.dto.AudienceUser;
|
||||
import com.xboe.data.dto.UserData;
|
||||
import com.xboe.data.dto.UserOrgIds;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -162,8 +163,10 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getOrgIds() {
|
||||
public UserOrgIds getOrgIds() {
|
||||
UserOrgIds uids=new UserOrgIds();
|
||||
List<String> orgIds = new ArrayList<>();
|
||||
uids.setIds(orgIds);
|
||||
String token = TokenProxy.getToken(request);
|
||||
String type="application/json";
|
||||
String[] headers=new String[] {"token",token,"Content-Type",type};
|
||||
@@ -178,7 +181,14 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
log.error("获取当前用户拥有权限机构id错误:"+responseStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
//对权限进行检查
|
||||
if(rootNode.has("permissions")) {
|
||||
JsonNode isAdminNode = rootNode.get("permissions").get("isSystemAdmin");
|
||||
if(isAdminNode!=null) {
|
||||
uids.getPermissions().put(UserOrgIds.IsSystemAdminKey, isAdminNode.asBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
if(rootNode.get("result")!=null & rootNode.get("result").isArray()) {
|
||||
JsonNode result = rootNode.get("result");
|
||||
Iterator<JsonNode> elements = result.elements();
|
||||
@@ -189,7 +199,7 @@ public class OutSideDataServiceImpl implements IOutSideDataService {
|
||||
}catch (Exception e){
|
||||
log.error("获取当前用户有权限的机构id错误",e);
|
||||
}
|
||||
return orgIds;
|
||||
return uids;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,7 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService{
|
||||
if(user.getDeleted()!=null) {
|
||||
a.setDeleted(user.getDeleted());
|
||||
}
|
||||
|
||||
a.setLoginName(user.getCode());
|
||||
|
||||
}else {
|
||||
//新账户
|
||||
a=new Account();
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.LikeMatchMode;
|
||||
import com.xboe.core.upload.XFileUploader;
|
||||
import com.xboe.data.dto.UserOrgIds;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.module.course.entity.CourseFile;
|
||||
import com.xboe.module.course.service.ICourseFileService;
|
||||
@@ -106,14 +107,23 @@ public class CourseFileApi extends ApiBaseController {
|
||||
}
|
||||
//增加权限的过滤,只要看到自己或有权限的机构的
|
||||
if(TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
||||
List<String> orgIds = outSideDataService.getOrgIds();
|
||||
UserOrgIds userOrgIds=outSideDataService.getOrgIds();
|
||||
List<String> orgIds = userOrgIds.getIds();
|
||||
String aid=getCurrent().getAccountId();
|
||||
if(!orgIds.isEmpty()){
|
||||
//filters.add(FieldFilters.in("orgId", orgIds));
|
||||
filters.add(FieldFilters.or(FieldFilters.eq("sysCreateAid", aid),FieldFilters.in("orgId", orgIds)));
|
||||
}else {
|
||||
filters.add(FieldFilters.eq("sysCreateAid", aid));
|
||||
//如果是超级管理员,就不按机构过滤了
|
||||
boolean isSystemAdmin=false;
|
||||
if(userOrgIds.getPermissions().containsKey(UserOrgIds.IsSystemAdminKey)) {
|
||||
isSystemAdmin=userOrgIds.getPermissions().get(UserOrgIds.IsSystemAdminKey);
|
||||
}
|
||||
if(!isSystemAdmin) {
|
||||
if(!orgIds.isEmpty()){
|
||||
//filters.add(FieldFilters.in("orgId", orgIds));
|
||||
filters.add(FieldFilters.or(FieldFilters.eq("sysCreateAid", aid),FieldFilters.in("orgId", orgIds)));
|
||||
}else {
|
||||
filters.add(FieldFilters.eq("sysCreateAid", aid));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//默认是查询自己的课件。
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.core.log.AutoLog;
|
||||
import com.xboe.data.dto.UserOrgIds;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.externalinterface.system.service.IFwUserService;
|
||||
import com.xboe.module.assistance.service.IEmailService;
|
||||
@@ -112,9 +113,20 @@ public class CourseManageApi extends ApiBaseController{
|
||||
public JsonResponse<PageList<Course>> findPage(Pagination pager,CourseQueryDto dto){
|
||||
|
||||
//增加权限的过滤,只要看到自己或有权限的机构的
|
||||
//getCurrent().get
|
||||
try {
|
||||
List<String> orgIds = outSideDataService.getOrgIds();
|
||||
String ids= StringUtils.join(orgIds,",");
|
||||
UserOrgIds userOrgIds=outSideDataService.getOrgIds();
|
||||
List<String> orgIds = userOrgIds.getIds();
|
||||
if(userOrgIds.getPermissions().containsKey(UserOrgIds.IsSystemAdminKey)) {
|
||||
dto.setIsSystemAdmin(userOrgIds.getPermissions().get(UserOrgIds.IsSystemAdminKey));
|
||||
}else {
|
||||
dto.setIsSystemAdmin(false);
|
||||
}
|
||||
String ids="";
|
||||
if(userOrgIds.getIds()!=null && !userOrgIds.getIds().isEmpty())
|
||||
{
|
||||
ids= StringUtils.join(orgIds,",");
|
||||
}
|
||||
//log.info("获取到的用户的组织机构权限ids",ids);
|
||||
String aid=getCurrent().getAccountId();
|
||||
//如果前端查询当前人的,这里去掉
|
||||
|
||||
@@ -104,4 +104,9 @@ public class CourseQueryDto {
|
||||
|
||||
/**用户权限的查询*/
|
||||
private String orgAid;
|
||||
|
||||
/**
|
||||
* 是否是超级管理员
|
||||
*/
|
||||
private Boolean isSystemAdmin;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -38,7 +37,6 @@ import com.xboe.system.logs.entity.SysLogLogin;
|
||||
import com.xboe.system.logs.service.ISysLogLoginService;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
import com.xboe.system.user.vo.UserVo;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -207,6 +205,7 @@ public class PortalLoginApi extends ApiBaseController {
|
||||
if (StringUtil.isBlank(token)) {
|
||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
||||
}
|
||||
|
||||
Map<String, String> tokenInfo = authorizationToken.readToken(token);
|
||||
if (tokenInfo == null) {
|
||||
return wrap(JsonResponseStatus.TOKEN_NOPASS, "token error");
|
||||
|
||||
@@ -306,19 +306,19 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
if(StringUtils.isBlank(sci.getContentId())){
|
||||
return error("参数错误:内容");
|
||||
}
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
// LocalDateTime now=LocalDateTime.now();
|
||||
CurrentUser cuser=getCurrent();
|
||||
|
||||
//下面的学习时长应该去掉了,不需要
|
||||
StudyTime st=new StudyTime();
|
||||
st.setContentId(sci.getContentId());
|
||||
st.setCourseId(sci.getCourseId());
|
||||
st.setDuration(5);//增加5秒的学习时长
|
||||
st.setEndTime(now);
|
||||
st.setStartTime(now);
|
||||
st.setStudentId(cuser.getAccountId());
|
||||
st.setStudentName(cuser.getName());
|
||||
st.setStudyId(sci.getStudyId());
|
||||
// StudyTime st=new StudyTime();
|
||||
// st.setContentId(sci.getContentId());
|
||||
// st.setCourseId(sci.getCourseId());
|
||||
// st.setDuration(5);//增加5秒的学习时长
|
||||
// st.setEndTime(now);
|
||||
// st.setStartTime(now);
|
||||
// st.setStudentId(cuser.getAccountId());
|
||||
// st.setStudentName(cuser.getName());
|
||||
// st.setStudyId(sci.getStudyId());
|
||||
|
||||
//检查是否已存在
|
||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||
@@ -328,7 +328,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),sci.getProgress());
|
||||
}
|
||||
//追加学习时长
|
||||
studyService.appendStudyDuration(st);
|
||||
//studyService.appendStudyDuration(st);
|
||||
return success(item.getId());
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
sci.setAname(cuser.getName());
|
||||
studyService.saveStudyInfo(sci);
|
||||
//学习记录成功后处理
|
||||
studyService.appendStudyDuration(st);
|
||||
//studyService.appendStudyDuration(st);
|
||||
return success(sci.getStudyItemId());
|
||||
}catch(Exception e) {
|
||||
log.error("记录学习课程内容完成错误",e);
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.module.course.dao.CourseContentDao;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
|
||||
@Repository
|
||||
public class StudyCourseDao extends BaseDao<StudyCourse> {
|
||||
@@ -27,7 +28,8 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
|
||||
* @param total
|
||||
*/
|
||||
public void finishCheck(String studyId,String courseId,Integer total){
|
||||
int n=scItemDao.count(FieldFilters.eq("studyId",studyId));
|
||||
//已完成的内容
|
||||
int n=scItemDao.count(FieldFilters.eq("studyId",studyId),FieldFilters.eq("status",StudyCourseItem.STATUS_FINISH));
|
||||
if(total==null) {
|
||||
total=courseContentDao.count(FieldFilters.eq("courseId", courseId),FieldFilters.eq("deleted",false));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface IStudyService {
|
||||
* @param studyContentId
|
||||
* @param progress
|
||||
*/
|
||||
void updateProcess(String studyContentId,String studyId, String courseId,int total,Integer progress);
|
||||
void updateProcess(String studyContentId,String studyId, String courseId,Integer total,Integer progress);
|
||||
|
||||
/**
|
||||
* 更新最后的学习时间,及学习时间点
|
||||
|
||||
@@ -61,24 +61,36 @@ public class StudyServiceImpl implements IStudyService{
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveStudyInfo(StudyContentDto dto) {
|
||||
//记录课程学习信息
|
||||
StudyCourseItem sci=new StudyCourseItem();
|
||||
StudyCourseItem sci = scItemDao.findOne(FieldFilters.eq("studyId", dto.getStudyId()),FieldFilters.eq("contentId", dto.getContentId()),FieldFilters.eq("aid", dto.getAid()));
|
||||
LocalDateTime ldt=LocalDateTime.now();
|
||||
sci.setStudyId(dto.getStudyId());
|
||||
sci.setContentId(dto.getContentId());
|
||||
sci.setContentName(dto.getContentName());
|
||||
sci.setCourseId(dto.getCourseId());
|
||||
|
||||
sci.setCsectionId(dto.getCsectionId());
|
||||
sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setStartTime(ldt);
|
||||
sci.setAid(dto.getAid());
|
||||
sci.setAname(dto.getAname());
|
||||
sci.setFinishTime(LocalDateTime.now());
|
||||
sci.setLastStudyTime(0);//此项用户记录视频内容当前学习的时间点
|
||||
if(sci==null) {
|
||||
sci=new StudyCourseItem();
|
||||
sci.setStartTime(ldt);
|
||||
sci.setAid(dto.getAid());
|
||||
sci.setAname(dto.getAname());
|
||||
sci.setLastStudyTime(0);//此项用户记录视频内容当前学习的时间点
|
||||
sci.setStudyId(dto.getStudyId());
|
||||
sci.setContentId(dto.getContentId());
|
||||
sci.setContentName(dto.getContentName());
|
||||
sci.setCourseId(dto.getCourseId());
|
||||
sci.setCsectionId(dto.getCsectionId());
|
||||
}
|
||||
//进度状态
|
||||
if(dto.getProgress()==null) {
|
||||
sci.setProgress(1);
|
||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||
}else if(dto.getProgress().intValue()==100) {
|
||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||
sci.setProgress(100);
|
||||
}else {
|
||||
sci.setStatus(StudyCourseItem.STATUS_STUDYING);
|
||||
sci.setProgress(dto.getProgress());
|
||||
}
|
||||
//sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setFinishTime(ldt);
|
||||
sci.setLastTime(ldt);
|
||||
sci.setStatus(StudyCourseItem.STATUS_FINISH);
|
||||
scItemDao.save(sci);
|
||||
scItemDao.saveOrUpdate(sci);
|
||||
|
||||
dto.setStudyItemId(sci.getId());
|
||||
//检查是否全部学习完成
|
||||
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal());
|
||||
@@ -144,8 +156,12 @@ public class StudyServiceImpl implements IStudyService{
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateProcess(String studyContentId,String studyId, String courseId,int total, Integer progress) {
|
||||
scItemDao.updateMultiFieldById(studyContentId, UpdateBuilder.create("progress",progress));
|
||||
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress) {
|
||||
int status=StudyCourseItem.STATUS_STUDYING;
|
||||
if(progress.intValue()==100) {
|
||||
status=StudyCourseItem.STATUS_FINISH;
|
||||
}
|
||||
scItemDao.updateMultiFieldById(studyContentId,UpdateBuilder.create("progress",progress),UpdateBuilder.create("status",status));
|
||||
//检查是否全部学习完成
|
||||
scDao.finishCheck(studyId,courseId,total);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user