课件资源库
parent
5e4a997f33
commit
244241b14e
|
@ -0,0 +1,706 @@
|
||||||
|
package com.zcloud.controller.eduBus;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.zcloud.controller.base.BaseController;
|
||||||
|
import com.zcloud.entity.Page;
|
||||||
|
import com.zcloud.entity.PageData;
|
||||||
|
import com.zcloud.service.eduBus.ChapterService;
|
||||||
|
import com.zcloud.service.eduBus.CurriculumService;
|
||||||
|
import com.zcloud.service.eduBus.VideoCoursewareService;
|
||||||
|
import com.zcloud.service.eduGateway.SynchronizeInformationService;
|
||||||
|
import com.zcloud.service.eduSystem.AnalysisService;
|
||||||
|
import com.zcloud.util.*;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author fangjiakai
|
||||||
|
* @date 2022/9/19/019 11:56
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/videoRes")
|
||||||
|
public class VideoResController extends BaseController {
|
||||||
|
|
||||||
|
@Value("${customer.id}")
|
||||||
|
private String customerId;
|
||||||
|
|
||||||
|
@Value("${customer.SECRET_KEY}")
|
||||||
|
private String customer_secret_key;
|
||||||
|
|
||||||
|
@Value("${customer.url}")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Value("${customer.domain}")
|
||||||
|
private String domain;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CurriculumService curriculumService;
|
||||||
|
@Autowired
|
||||||
|
private VideoCoursewareService videoCoursewareService;
|
||||||
|
@Autowired
|
||||||
|
private ChapterService chapterService;
|
||||||
|
@Autowired
|
||||||
|
private SynchronizeInformationService synchronizeInformationService;
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private DockingCurriculumService dockingCurriculumService;
|
||||||
|
@Autowired
|
||||||
|
private AnalysisService analysisService;
|
||||||
|
|
||||||
|
// @Resource
|
||||||
|
// private ViedoResService viedoResService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InitPageDataUtil initPageDataUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/list")
|
||||||
|
@RequiresPermissions("videoRes:list")
|
||||||
|
@ResponseBody
|
||||||
|
public Object list(Page page) throws Exception {
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
|
||||||
|
if (Tools.notEmpty(KEYWORDS)) {
|
||||||
|
pd.put("KEYWORDS", KEYWORDS.trim());
|
||||||
|
}
|
||||||
|
page.setPd(pd);
|
||||||
|
Map<String, String> request = new HashMap<String, String>();
|
||||||
|
request.put("id", this.customerId);
|
||||||
|
String key = MD5.md5(this.customer_secret_key + domain);
|
||||||
|
request.put("SECRET_KEY", key);
|
||||||
|
request.put("KEYWORDS", KEYWORDS);
|
||||||
|
request.put("showCount", String.valueOf(page.getShowCount()));
|
||||||
|
request.put("currentPage", String.valueOf(page.getCurrentPageInit()));
|
||||||
|
String response = HttpRequestUtil.doPost(url + "/curriculum/getCurList", JSONObject.toJSONString(request));
|
||||||
|
JSONObject responseResult = JSONObject.parseObject(response);
|
||||||
|
|
||||||
|
if (responseResult != null && responseResult.get("code") != null && Tools.notEmpty(responseResult.get("code").toString()) && "0".equals(responseResult.get("code"))) {
|
||||||
|
map.put("varList", responseResult.getJSONArray("curriculumList"));
|
||||||
|
map.put("page", responseResult.getJSONObject("page"));
|
||||||
|
} else {
|
||||||
|
map.put("message", "请求出错,请联系管理员。");
|
||||||
|
}
|
||||||
|
// List<PageData> varList = videocoursewareService.list(page); //列出VideoCourseware列表
|
||||||
|
// map.put("page", page);
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新所有课程
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
// @RequestMapping(value = "/updNow")
|
||||||
|
// @RequiresPermissions("videoRes:list")
|
||||||
|
// @ResponseBody
|
||||||
|
// public Object updNow(Page page) throws Exception {
|
||||||
|
// Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
// String errInfo = "success";
|
||||||
|
// PageData pd = new PageData();
|
||||||
|
// pd = this.getPageData();
|
||||||
|
// pd.put("id", this.customerId);
|
||||||
|
// String key = MD5.md5(this.customer_secret_key + domain);
|
||||||
|
// pd.put("SECRET_KEY", key);
|
||||||
|
// pd.put("KEYWORDS", "(2023)尼特智能科技股份有限公司(车间)班组级安全教育培训");
|
||||||
|
//
|
||||||
|
// String msg = viedoResService.updAllNow(pd);
|
||||||
|
// if (StringUtils.isNotEmpty(msg)) {
|
||||||
|
// map.put("result", "error");
|
||||||
|
// map.put("message", msg);
|
||||||
|
// } else {
|
||||||
|
// map.put("result", errInfo);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// return map;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/upgradeVideoList")
|
||||||
|
@RequiresPermissions("videoRes:list")
|
||||||
|
@ResponseBody
|
||||||
|
public Object upgradeVideoList(Page page) throws Exception {
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
|
||||||
|
if (Tools.notEmpty(KEYWORDS)) pd.put("KEYWORDS", KEYWORDS.trim());
|
||||||
|
page.setPd(pd);
|
||||||
|
Map<String, String> request = new HashMap<String, String>();
|
||||||
|
request.put("id", this.customerId);
|
||||||
|
String key = MD5.md5(this.customer_secret_key + domain);
|
||||||
|
request.put("SECRET_KEY", key);
|
||||||
|
request.put("KEYWORDS", KEYWORDS);
|
||||||
|
request.put("showCount", String.valueOf(page.getShowCount()));
|
||||||
|
request.put("currentPage", String.valueOf(page.getCurrentPageInit()));
|
||||||
|
String response = HttpRequestUtil.doPost(url + "/videoCourseware/getUpgradeVideoList", JSONObject.toJSONString(request));
|
||||||
|
JSONObject responseResult = JSONObject.parseObject(response);
|
||||||
|
|
||||||
|
if (responseResult != null && responseResult.get("code") != null && Tools.notEmpty(responseResult.get("code").toString()) && "0".equals(responseResult.get("code"))) {
|
||||||
|
map.put("page", responseResult.getJSONObject("page"));
|
||||||
|
List<PageData> list = analysisService.analysisVideoList(responseResult.getJSONArray("videoList"));
|
||||||
|
map.put("varList", list);
|
||||||
|
} else {
|
||||||
|
map.put("message", "请求出错,请联系管理员。");
|
||||||
|
}
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去修改页面获取数据
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/goEdit")
|
||||||
|
@RequiresPermissions("videoRes:edit")
|
||||||
|
@ResponseBody
|
||||||
|
public Object goEdit() throws Exception {
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
|
||||||
|
Map<String, String> request = new HashMap<String, String>();
|
||||||
|
request.put("CURRICULUM_ID", pd.get("CURRICULUM_ID").toString());
|
||||||
|
request.put("id", this.customerId);
|
||||||
|
String key = MD5.md5(this.customer_secret_key + domain);
|
||||||
|
request.put("SECRET_KEY", key);
|
||||||
|
String response = HttpRequestUtil.doPost(url + "/curriculum/getCurInfo", JSONObject.toJSONString(request));
|
||||||
|
JSONObject responseResult = JSONObject.parseObject(response);
|
||||||
|
if (responseResult != null && responseResult.get("code") != null && Tools.notEmpty(responseResult.get("code").toString()) && "0".equals(responseResult.get("code"))) {
|
||||||
|
map.put("pd", responseResult.getJSONObject("pd"));
|
||||||
|
map.put("chapterList", responseResult.getJSONArray("chapterList"));
|
||||||
|
} else {
|
||||||
|
errInfo = "warning";
|
||||||
|
map.put("message", "请求出错,请联系管理员。");
|
||||||
|
}
|
||||||
|
// map.put("chapterList", chapterList);
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去修改页面获取数据
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/goVideoEdit")
|
||||||
|
@ResponseBody
|
||||||
|
public Object goVideoEdit() throws Exception {
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
|
||||||
|
pd.put("TYPE", "1");
|
||||||
|
JSONObject response = synchronizeInformationService.syncVideoInfo(pd);
|
||||||
|
if (response != null) {
|
||||||
|
if (response.get("code") != null && Tools.notEmpty(response.get("code").toString()) && "0".equals(response.get("code"))) {
|
||||||
|
map.put("pd", response.getJSONObject("video"));
|
||||||
|
} else {
|
||||||
|
errInfo = "warning";
|
||||||
|
map.put("message", response.get("errorMessage"));
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errInfo = "warning";
|
||||||
|
map.put("message", "请求出错,请联系管理员。");
|
||||||
|
}
|
||||||
|
// map.put("chapterList", chapterList);
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加课程
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/syncCurriculum")
|
||||||
|
@RequiresPermissions("videoRes:edit")
|
||||||
|
@ResponseBody
|
||||||
|
public Object syncCurriculum() throws Exception {
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
PageData curRemote = new PageData();
|
||||||
|
curRemote.put("CURRICULUM_ID_REMOTE", pd.get("CURRICULUM_ID"));
|
||||||
|
// 验证是否添加过此课程
|
||||||
|
PageData curriculumRes = curriculumService.findByRemoteId(curRemote);
|
||||||
|
if (curriculumRes != null && curriculumRes.get("CURRICULUM_ID") != null && Tools.notEmpty(curriculumRes.get("CURRICULUM_ID").toString())) {
|
||||||
|
map.put("message", "该课程已添加。无需二次添加。");
|
||||||
|
errInfo = "warning";
|
||||||
|
} else {
|
||||||
|
Map<String, String> request = new HashMap<String, String>();
|
||||||
|
request.put("CURRICULUM_ID", pd.get("CURRICULUM_ID").toString());
|
||||||
|
request.put("id", this.customerId);
|
||||||
|
String key = MD5.md5(this.customer_secret_key + domain);
|
||||||
|
request.put("SECRET_KEY", key);
|
||||||
|
String response = HttpRequestUtil.doPost(url + "/curriculum/getCurInfo", JSONObject.toJSONString(request));
|
||||||
|
JSONObject responseResult = JSONObject.parseObject(response);
|
||||||
|
if (responseResult != null && responseResult.get("code") != null && Tools.notEmpty(responseResult.get("code").toString()) && "0".equals(responseResult.get("code"))) {
|
||||||
|
JSONObject curricullum = responseResult.getJSONObject("pd");
|
||||||
|
List<JSONObject> chapterList = JSON.parseArray(responseResult.getString("chapterList"), JSONObject.class);
|
||||||
|
PageData cur = new PageData();
|
||||||
|
PageData idDate = new PageData();
|
||||||
|
// 保存课程
|
||||||
|
if (curricullum != null && curricullum.get("CURRICULUM_ID") != null) {
|
||||||
|
cur.put("CURRICULUM_ID", this.get32UUID());
|
||||||
|
cur.put("CURRICULUM_ID_REMOTE", curricullum.get("CURRICULUM_ID"));
|
||||||
|
cur.put("CLASSHOUR", curricullum.getString("CLASSHOUR"));
|
||||||
|
cur.put("CURRICULUMNAME", curricullum.getString("CURRICULUMNAME"));
|
||||||
|
cur.put("CURRICULUMINTRODUCE", curricullum.getString("CURRICULUMINTRODUCE"));
|
||||||
|
cur.put("CATALOGUELEVEL", curricullum.getString("CATALOGUELEVEL"));
|
||||||
|
cur.put("VIDEOTIME", curricullum.getString("VIDEOTIME"));
|
||||||
|
cur.put("COLLECTIVE", 0);
|
||||||
|
cur.put("ISDELETE", "0");
|
||||||
|
cur.put("ISSELL", "0");
|
||||||
|
cur.put("VALID_DATE", Tools.isEmpty(curricullum.getString("VALID_DATE")) ? "" : curricullum.getString("VALID_DATE"));
|
||||||
|
cur.put("CREATOR", Jurisdiction.getUsername()); //添加人
|
||||||
|
cur.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
||||||
|
cur.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||||||
|
cur.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||||||
|
cur.put("ISCOMPLETE", "0");
|
||||||
|
cur.put("STATE", "1");
|
||||||
|
curriculumService.save(cur);
|
||||||
|
// 加入本地
|
||||||
|
initPageDataUtil.initEdit(pd);
|
||||||
|
// dockingCurriculumService.addLocal(pd);
|
||||||
|
}
|
||||||
|
idDate.put("CURRICULUM_ID", cur.get("CURRICULUM_ID"));
|
||||||
|
// 保存章节及视频
|
||||||
|
if (chapterList != null && chapterList.size() > 0) {
|
||||||
|
for (JSONObject chapter : chapterList) {
|
||||||
|
PageData video = new PageData();
|
||||||
|
// todo 关联课件时,查询课件是否保存过,如果没保存过,进行保存 2023-04-03 修改为 保存一次课程 就保存其中的课件 并把 课程的过期时间 赋给课件
|
||||||
|
if (chapter.get("VIDEOCOURSEWARE_ID") != null && Tools.notEmpty(chapter.get("VIDEOCOURSEWARE_ID").toString())) {
|
||||||
|
chapter.put("SOURCE", "2");
|
||||||
|
chapter.put("LIMIT_TIME", Tools.isEmpty(curricullum.getString("VALID_DATE")) ? "" : curricullum.getString("VALID_DATE"));
|
||||||
|
chapter.put("CURRICULUM_ID_REMOTE", curricullum.get("CURRICULUM_ID")); //存储原课程ID
|
||||||
|
video = saveOrUpdateVideo(chapter);
|
||||||
|
} else {
|
||||||
|
video.put("VIDEOCOURSEWARE_ID", "");
|
||||||
|
}
|
||||||
|
idDate.put("pid", "0");
|
||||||
|
idDate.put("VIDEOCOURSEWARE_ID", video.getString("VIDEOCOURSEWARE_ID"));
|
||||||
|
// 保存章节数据
|
||||||
|
PageData cha = saveChapter(chapter, idDate);
|
||||||
|
// 查看是否有下级章节
|
||||||
|
if (chapter.get("nodes") != null && Tools.notEmpty(chapter.get("nodes").toString())) {
|
||||||
|
List<JSONObject> nodes = (List<JSONObject>) JSON.parse(chapter.get("nodes").toString());
|
||||||
|
if (nodes != null && nodes.size() > 0) {
|
||||||
|
for (JSONObject node : nodes) {
|
||||||
|
PageData childVideo = new PageData();
|
||||||
|
// 关联课件时,查询课件是否保存过,如果没保存过,进行保存
|
||||||
|
if (node.get("VIDEOCOURSEWARE_ID") != null && Tools.notEmpty(node.get("VIDEOCOURSEWARE_ID").toString())) {
|
||||||
|
node.put("SOURCE", "2");
|
||||||
|
node.put("LIMIT_TIME", Tools.isEmpty(curricullum.getString("VALID_DATE")) ? "" : curricullum.getString("VALID_DATE"));
|
||||||
|
node.put("CURRICULUM_ID_REMOTE", curricullum.get("CURRICULUM_ID")); //存储原课程ID
|
||||||
|
childVideo = saveOrUpdateVideo(node);
|
||||||
|
PageData sdafas = new PageData();
|
||||||
|
PageData sdafas1 = new PageData();
|
||||||
|
System.out.println(sdafas1);
|
||||||
|
} else {
|
||||||
|
childVideo.put("VIDEOCOURSEWARE_ID", "");
|
||||||
|
}
|
||||||
|
idDate.put("pid", cha.getString("CHAPTER_ID"));
|
||||||
|
idDate.put("VIDEOCOURSEWARE_ID", childVideo.getString("VIDEOCOURSEWARE_ID"));
|
||||||
|
// 保存章节数据
|
||||||
|
PageData childCha = saveChapter(node, idDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errInfo = "warning";
|
||||||
|
map.put("message", "请求出错,请联系管理员。");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 批量添加课程
|
||||||
|
// *
|
||||||
|
// * @param
|
||||||
|
// * @throws Exception
|
||||||
|
// */
|
||||||
|
// @RequestMapping(value = "/batchAddCourses")
|
||||||
|
// @RequiresPermissions("videoRes:edit")
|
||||||
|
// @ResponseBody
|
||||||
|
// public Object batchAddCourses() throws Exception {
|
||||||
|
//
|
||||||
|
// Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
// String errInfo = "success";
|
||||||
|
// PageData data = new PageData();
|
||||||
|
// data = this.getPageData();
|
||||||
|
// data.put("COLLECTIVE","1");
|
||||||
|
// data.put("CURRICULUM_ID","1");
|
||||||
|
// data.put("ISDELETE","1");
|
||||||
|
// curriculumService.save(data);
|
||||||
|
//
|
||||||
|
// map.put("result", errInfo);
|
||||||
|
// return map;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加课程
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/batchAddCourses")
|
||||||
|
@RequiresPermissions("videoRes:edit")
|
||||||
|
@ResponseBody
|
||||||
|
@Transactional
|
||||||
|
public Object batchAddCourses() throws Exception {
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData data = new PageData();
|
||||||
|
data = this.getPageData();
|
||||||
|
List<PageData> idList = JSONObject.parseArray(data.getString("idList"), PageData.class);
|
||||||
|
for (PageData pd : idList) {
|
||||||
|
PageData curRemote = new PageData();
|
||||||
|
curRemote.put("CURRICULUM_ID_REMOTE", pd.get("CURRICULUM_ID"));
|
||||||
|
// 验证是否添加过此课程
|
||||||
|
PageData curriculumRes = curriculumService.findByRemoteId(curRemote);
|
||||||
|
if (curriculumRes != null && curriculumRes.get("CURRICULUM_ID") != null && Tools.notEmpty(curriculumRes.get("CURRICULUM_ID").toString())) {
|
||||||
|
map.put("message", "该课程已添加。无需二次添加。");
|
||||||
|
errInfo = "warning";
|
||||||
|
} else {
|
||||||
|
Map<String, String> request = new HashMap<String, String>();
|
||||||
|
request.put("CURRICULUM_ID", pd.get("CURRICULUM_ID").toString());
|
||||||
|
request.put("id", this.customerId);
|
||||||
|
String key = MD5.md5(this.customer_secret_key + domain);
|
||||||
|
request.put("SECRET_KEY", key);
|
||||||
|
String response = HttpRequestUtil.doPost(url + "/curriculum/getCurInfo", JSONObject.toJSONString(request));
|
||||||
|
JSONObject responseResult = JSONObject.parseObject(response);
|
||||||
|
if (responseResult != null && responseResult.get("code") != null && Tools.notEmpty(responseResult.get("code").toString()) && "0".equals(responseResult.get("code"))) {
|
||||||
|
JSONObject curricullum = responseResult.getJSONObject("pd");
|
||||||
|
List<JSONObject> chapterList = JSON.parseArray(responseResult.getString("chapterList"), JSONObject.class);
|
||||||
|
PageData cur = new PageData();
|
||||||
|
PageData idDate = new PageData();
|
||||||
|
|
||||||
|
// 保存课程
|
||||||
|
if (curricullum != null && curricullum.get("CURRICULUM_ID") != null) {
|
||||||
|
cur.put("CURRICULUM_ID", this.get32UUID());
|
||||||
|
cur.put("CURRICULUM_ID_REMOTE", curricullum.get("CURRICULUM_ID"));
|
||||||
|
cur.put("CLASSHOUR", curricullum.getString("CLASSHOUR"));
|
||||||
|
cur.put("CURRICULUMNAME", curricullum.getString("CURRICULUMNAME"));
|
||||||
|
cur.put("CURRICULUMINTRODUCE", curricullum.getString("CURRICULUMINTRODUCE"));
|
||||||
|
cur.put("CATALOGUELEVEL", curricullum.getString("CATALOGUELEVEL"));
|
||||||
|
cur.put("VIDEOTIME", curricullum.getString("VIDEOTIME"));
|
||||||
|
cur.put("COLLECTIVE", 0);
|
||||||
|
cur.put("ISDELETE", "0");
|
||||||
|
cur.put("ISSELL", "0");
|
||||||
|
cur.put("VALID_DATE", Tools.isEmpty(curricullum.getString("VALID_DATE")) ? "" : curricullum.getString("VALID_DATE"));
|
||||||
|
cur.put("CREATOR", Jurisdiction.getUsername()); //添加人
|
||||||
|
cur.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
||||||
|
cur.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||||||
|
cur.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||||||
|
cur.put("ISCOMPLETE", "0");
|
||||||
|
cur.put("STATE", "1");
|
||||||
|
curriculumService.save(cur);
|
||||||
|
// 加入本地
|
||||||
|
initPageDataUtil.initEdit(pd);
|
||||||
|
// dockingCurriculumService.addLocal(pd);
|
||||||
|
}
|
||||||
|
idDate.put("CURRICULUM_ID", cur.get("CURRICULUM_ID"));
|
||||||
|
// 保存章节及视频
|
||||||
|
if (chapterList != null && chapterList.size() > 0) {
|
||||||
|
for (JSONObject chapter : chapterList) {
|
||||||
|
PageData video = new PageData();
|
||||||
|
// todo 关联课件时,查询课件是否保存过,如果没保存过,进行保存 2023-04-03 修改为 保存一次课程 就保存其中的课件 并把 课程的过期时间 赋给课件
|
||||||
|
if (chapter.get("VIDEOCOURSEWARE_ID") != null && Tools.notEmpty(chapter.get("VIDEOCOURSEWARE_ID").toString())) {
|
||||||
|
chapter.put("SOURCE", "2");
|
||||||
|
chapter.put("LIMIT_TIME", Tools.isEmpty(curricullum.getString("VALID_DATE")) ? "" : curricullum.getString("VALID_DATE"));
|
||||||
|
chapter.put("CURRICULUM_ID_REMOTE", curricullum.get("CURRICULUM_ID")); //存储原课程ID
|
||||||
|
video = saveOrUpdateVideo(chapter);
|
||||||
|
} else {
|
||||||
|
video.put("VIDEOCOURSEWARE_ID", "");
|
||||||
|
}
|
||||||
|
idDate.put("pid", "0");
|
||||||
|
idDate.put("VIDEOCOURSEWARE_ID", video.getString("VIDEOCOURSEWARE_ID"));
|
||||||
|
// 保存章节数据
|
||||||
|
PageData cha = saveChapter(chapter, idDate);
|
||||||
|
// 查看是否有下级章节
|
||||||
|
if (chapter.get("nodes") != null && Tools.notEmpty(chapter.get("nodes").toString())) {
|
||||||
|
List<JSONObject> nodes = (List<JSONObject>) JSON.parse(chapter.get("nodes").toString());
|
||||||
|
if (nodes != null && nodes.size() > 0) {
|
||||||
|
for (JSONObject node : nodes) {
|
||||||
|
PageData childVideo = new PageData();
|
||||||
|
// 关联课件时,查询课件是否保存过,如果没保存过,进行保存
|
||||||
|
if (node.get("VIDEOCOURSEWARE_ID") != null && Tools.notEmpty(node.get("VIDEOCOURSEWARE_ID").toString())) {
|
||||||
|
node.put("SOURCE", "2");
|
||||||
|
node.put("LIMIT_TIME", Tools.isEmpty(curricullum.getString("VALID_DATE")) ? "" : curricullum.getString("VALID_DATE"));
|
||||||
|
node.put("CURRICULUM_ID_REMOTE", curricullum.get("CURRICULUM_ID")); //存储原课程ID
|
||||||
|
childVideo = saveOrUpdateVideo(node);
|
||||||
|
} else {
|
||||||
|
childVideo.put("VIDEOCOURSEWARE_ID", "");
|
||||||
|
}
|
||||||
|
idDate.put("pid", cha.getString("CHAPTER_ID"));
|
||||||
|
idDate.put("VIDEOCOURSEWARE_ID", childVideo.getString("VIDEOCOURSEWARE_ID"));
|
||||||
|
// 保存章节数据
|
||||||
|
PageData childCha = saveChapter(node, idDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errInfo = "warning";
|
||||||
|
map.put("message", "请求出错,请联系管理员。");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去修改页面获取数据
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/syncVideo")
|
||||||
|
@RequiresPermissions("videoRes:edit")
|
||||||
|
@ResponseBody
|
||||||
|
public Object syncVideo() throws Exception {
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
PageData videoRemote = new PageData();
|
||||||
|
videoRemote.put("VIDEOCOURSEWARE_ID_REMOTE", pd.get("VIDEOCOURSEWARE_ID"));
|
||||||
|
// 验证是否添加过此课程
|
||||||
|
PageData videoRes = videoCoursewareService.findByRemoteId(videoRemote);
|
||||||
|
if (videoRes != null && videoRes.get("VIDEOCOURSEWARE_ID") != null && Tools.notEmpty(videoRes.get("VIDEOCOURSEWARE_ID").toString())) {
|
||||||
|
map.put("message", "该课件已添加。无需二次添加。");
|
||||||
|
errInfo = "warning";
|
||||||
|
} else {
|
||||||
|
pd.put("TYPE", "1");
|
||||||
|
JSONObject response = synchronizeInformationService.syncVideoInfo(pd);
|
||||||
|
if (response != null) {
|
||||||
|
if (response.get("code") != null && Tools.notEmpty(response.get("code").toString()) && "0".equals(response.get("code"))) {
|
||||||
|
JSONObject v = response.getJSONObject("video");
|
||||||
|
PageData video = new PageData();
|
||||||
|
video.put("VIDEOCOURSEWARE_ID_REMOTE", pd.get("VIDEOCOURSEWARE_ID"));
|
||||||
|
video.put("VIDEOCOURSEWARE_ID", this.get32UUID());
|
||||||
|
video.put("ISDELETE", "0");
|
||||||
|
video.put("CREATOR", Jurisdiction.getUsername()); //添加人
|
||||||
|
video.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
||||||
|
video.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||||||
|
video.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||||||
|
video.put("STATE", "0");
|
||||||
|
video.put("LIMIT_TIME", Tools.isEmpty(pd.getString("LIMIT_TIME")) ? "" : pd.getString("LIMIT_TIME"));
|
||||||
|
video.put("ISCOMPLETE", "0");
|
||||||
|
video.put("COURSEWARENAME", v.get("COURSEWARENAME"));
|
||||||
|
video.put("COURSEWAREINTRODUCE", v.get("COURSEWAREINTRODUCE"));
|
||||||
|
video.put("VIDEOFILES", v.get("VIDEOFILES"));
|
||||||
|
video.put("CLASSHOUR", v.get("CLASSHOUR"));
|
||||||
|
video.put("VIDEOTIME", v.get("VIDEOTIME"));
|
||||||
|
video.put("SOURCE", "3");
|
||||||
|
videoCoursewareService.save(video);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
errInfo = "warning";
|
||||||
|
map.put("message", response.get("errorMessage"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
errInfo = "warning";
|
||||||
|
map.put("message", "请求出错,请联系管理员。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去修改页面获取数据
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/getVideoPlayAuth")
|
||||||
|
@ResponseBody
|
||||||
|
public Object getVideoPlayAuth() throws Exception {
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
|
||||||
|
PageData playAuth = synchronizeInformationService.syncVideoPlayAuth(pd);
|
||||||
|
if (playAuth != null) {
|
||||||
|
if (playAuth.get("code") != null && "0".equals(playAuth.get("code"))) {
|
||||||
|
map.put("playAuth", playAuth.get("PlayAuth"));
|
||||||
|
map.put("message", "获取成功。");
|
||||||
|
} else {
|
||||||
|
map.put("message", playAuth.get("errorMessage"));
|
||||||
|
errInfo = "warning";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
map.put("message", "获取失败,请联系管理员。");
|
||||||
|
errInfo = "warning";
|
||||||
|
}
|
||||||
|
// map.put("chapterList", chapterList);
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 去修改页面获取数据
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/syncVideoPlayInfo")
|
||||||
|
@ResponseBody
|
||||||
|
public Object syncVideoPlayInfo() throws Exception {
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
String errInfo = "success";
|
||||||
|
PageData pd = new PageData();
|
||||||
|
pd = this.getPageData();
|
||||||
|
|
||||||
|
JSONObject playInfo = synchronizeInformationService.syncVideoPlayInfo(pd);
|
||||||
|
if (playInfo != null) {
|
||||||
|
if (playInfo.get("code") != null && "0".equals(playInfo.get("code"))) {
|
||||||
|
map.put("urlList", playInfo.get("urlList"));
|
||||||
|
map.put("message", "获取成功。");
|
||||||
|
} else {
|
||||||
|
map.put("message", playInfo.get("errorMessage"));
|
||||||
|
errInfo = "warning";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
map.put("message", "获取失败,请联系管理员。");
|
||||||
|
errInfo = "warning";
|
||||||
|
}
|
||||||
|
map.put("result", errInfo);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private PageData saveChapter(JSONObject oldCha, PageData idDate) throws Exception {
|
||||||
|
PageData newCha = new PageData();
|
||||||
|
newCha.put("CHAPTER_ID", this.get32UUID());
|
||||||
|
newCha.put("CHAPTER_ID_REMOTE", oldCha.get("CHAPTER_ID"));
|
||||||
|
newCha.put("CURRICULUM_ID", idDate.get("CURRICULUM_ID"));
|
||||||
|
newCha.put("ISDELETE", "0");
|
||||||
|
newCha.put("CREATOR", Jurisdiction.getUsername()); //添加人
|
||||||
|
newCha.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
||||||
|
newCha.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||||||
|
newCha.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||||||
|
newCha.put("NAME", oldCha.getString("NAME"));
|
||||||
|
newCha.put("SORT", oldCha.getString("SORT"));
|
||||||
|
newCha.put("PARENT_ID", idDate.get("pid"));
|
||||||
|
newCha.put("COURSEWARENAME", oldCha.getString("COURSEWARENAME"));
|
||||||
|
newCha.put("VIDEOFILES", oldCha.getString("VIDEOFILES"));
|
||||||
|
if (oldCha.get("nodes") == null) {
|
||||||
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
|
Double videoTime = Double.valueOf(oldCha.getString("VIDEOTIME"));
|
||||||
|
newCha.put("CLASSHOUR", df.format(videoTime / 60 / 45));
|
||||||
|
}
|
||||||
|
newCha.put("VIDEOTIME", oldCha.getString("VIDEOTIME"));
|
||||||
|
newCha.put("VIDEOCOURSEWARE_ID", idDate.get("VIDEOCOURSEWARE_ID"));
|
||||||
|
chapterService.save(newCha);
|
||||||
|
return newCha;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PageData saveVideo(JSONObject oldCha) throws Exception {
|
||||||
|
// 直接保存课件
|
||||||
|
PageData video = new PageData();
|
||||||
|
video.put("VIDEOCOURSEWARE_ID_REMOTE", oldCha.get("VIDEOCOURSEWARE_ID"));
|
||||||
|
video.put("VIDEOCOURSEWARE_ID", this.get32UUID());
|
||||||
|
video.put("ISDELETE", "0");
|
||||||
|
video.put("CREATOR", Jurisdiction.getUsername()); //添加人
|
||||||
|
video.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
|
||||||
|
video.put("OPERATOR", Jurisdiction.getUsername()); //修改人
|
||||||
|
video.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
|
||||||
|
video.put("STATE", "0");
|
||||||
|
video.put("LIMIT_TIME", oldCha.getString("LIMIT_TIME"));
|
||||||
|
video.put("ISCOMPLETE", "0");
|
||||||
|
video.put("COURSEWARENAME", oldCha.get("COURSEWARENAME"));
|
||||||
|
video.put("COURSEWAREINTRODUCE", oldCha.get("COURSEWAREINTRODUCE"));
|
||||||
|
video.put("VIDEOFILES", oldCha.get("VIDEOFILES"));
|
||||||
|
video.put("CLASSHOUR", oldCha.get("CLASSHOUR"));
|
||||||
|
video.put("VIDEOTIME", oldCha.get("VIDEOTIME"));
|
||||||
|
video.put("SOURCE", oldCha.get("SOURCE"));
|
||||||
|
video.put("CURRICULUM_ID_REMOTE", oldCha.get("CURRICULUM_ID_REMOTE"));
|
||||||
|
videoCoursewareService.save(video);
|
||||||
|
return video;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PageData saveOrUpdateVideo(JSONObject oldCha) throws Exception {
|
||||||
|
// 查询课件是否加入过本地
|
||||||
|
PageData oldVideo = new PageData();
|
||||||
|
oldVideo.put("VIDEOCOURSEWARE_ID_REMOTE", oldCha.get("VIDEOCOURSEWARE_ID"));
|
||||||
|
oldVideo = videoCoursewareService.findByRemoteId(oldVideo);
|
||||||
|
if(oldVideo != null && Tools.notEmpty(oldVideo.getString("VIDEOCOURSEWARE_ID"))){ // 已经保存过,判断期限,并保存
|
||||||
|
if(Tools.notEmpty(oldCha.getString("LIMIT_TIME"))){
|
||||||
|
boolean timeBoolean = DateUtil.compareDate(oldCha.getString("LIMIT_TIME"), oldVideo.getString("LIMIT_TIME"));
|
||||||
|
if(timeBoolean){
|
||||||
|
oldVideo.put("LIMIT_TIME", oldCha.getString("LIMIT_TIME"));
|
||||||
|
oldVideo.put("CURRICULUM_ID_REMOTE", oldCha.getString("CURRICULUM_ID_REMOTE"));
|
||||||
|
initPageDataUtil.initEdit(oldVideo);
|
||||||
|
videoCoursewareService.editLimitDate(oldVideo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// video = oldVideo;
|
||||||
|
return oldVideo;
|
||||||
|
} else { // 之前未存过,直接保存
|
||||||
|
return saveVideo(oldCha);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue