package com.zcloud.controller.courseware;

import com.aliyun.vod20170321.models.GetVideoInfoResponse;
import com.aliyun.vod20170321.models.GetVideoPlayAuthResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.vod.model.v20170321.GetTranscodeSummaryResponse;
import com.aliyuncs.vod.model.v20170321.GetTranscodeSummaryResponse.TranscodeSummary;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.logs.LogAnno;
import com.zcloud.service.courseware.QuestionService;
import com.zcloud.service.courseware.VideoCoursewareService;
import com.zcloud.service.curriculum.CurriculumService;
import com.zcloud.service.curriculum.KcmiddlekjService;
import com.zcloud.service.gateway.SynchronizeInformationService;
import com.zcloud.service.relation.CoursewareRelationService;
import com.zcloud.util.*;
import com.zcloud.util.ali.AudioOrVideoCreateUpload;
import com.zcloud.util.ali.GetVideoInfo;
import com.zcloud.util.ali.SubmitTrans;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;

/**
 * 说明：视频课件维护
 * 作者：luoxiaobao
 * 时间：2021-06-26
 * 官网：www.zcloudchina.com
 */
@Controller
@RequestMapping("/videocourseware")
public class VideoCoursewareController extends BaseController {


	@Autowired
	private VideoCoursewareService videocoursewareService;
	@Autowired
	private QuestionService questionService;
	@Autowired
	private KcmiddlekjService kcmiddlekjService;
	@Autowired
	private CoursewareRelationService coursewareRelationService;
	@Autowired
	private Smb smb;
	@Autowired
	private CurriculumService curriculumService;
	@Autowired
	private SynchronizeInformationService synchronizeInformationService;
	/**新增(非阿里云，暂时废弃)
	 * @param
	 * @throws Exception
	 */
//	@RequestMapping(value="/add")
//	// @RequiresPermissions("courseware:add")
//	@ResponseBody
//	public Object add(@RequestParam(value="vfile",required=false) MultipartFile vfile,
//					  @RequestParam(value="vcfile",required=false) MultipartFile vcfile) throws Exception{
//		Map<String,Object> map = new HashMap<String,Object>();
//		String errInfo = "success";
//		PageData pd = new PageData();
//		pd = this.getPageData();
//		pd.put("VIDEOCOURSEWARE_ID", this.get32UUID());	//主键
//		pd.put("CREATOR", Jurisdiction.getUsername());	//添加人
//		pd.put("CREATTIME", DateUtil.date2Str(new Date()));	//添加时间
//		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
//		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
//		pd.put("ISDELETE", "0");	//是否删除(0:有效 1：删除)
//		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
//		pd.put("STATE", "0");	//课件状态 0启用、1禁用
//		if (null != vfile && !vfile.isEmpty()) {
//			String  ffile = DateUtil.getDays();
//			//本地
////			String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile;	//文件上传路径
////			String fileName = FileUpload.fileUp(file, filePath, this.get32UUID());				//执行上传
//			//服务器
//			String fileName = this.get32UUID()+vfile.getOriginalFilename().substring(vfile.getOriginalFilename().lastIndexOf("."));
//			smb.sshSftp(vfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
//			pd.put("VIDEOFILES", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
//			// 将MultipartFile file转换成为File
//			File f_file = FileUtil.MultipartFileToFile(vfile);
//			MultimediaObject instance = new MultimediaObject(f_file);
//			MultimediaInfo result = instance.getInfo();
//			System.out.println("视频时长："+result.getDuration());
//			double videoTime = (double)result.getDuration() / 1000.0;
//			pd.put("VIDEOTIME", videoTime+"");
//			f_file.delete();
//		}
//		if (null != vcfile && !vcfile.isEmpty()) {
//			String  ffile = DateUtil.getDays();
//			//本地
////			String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile;	//文件上传路径
////			String fileName = FileUpload.fileUp(file, filePath, this.get32UUID());				//执行上传
//			//服务器
//			String fileName = this.get32UUID()+vcfile.getOriginalFilename().substring(vcfile.getOriginalFilename().lastIndexOf("."));
//			smb.sshSftp(vcfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
//			pd.put("VIDEOCAPTURE", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
//		}
//		videocoursewareService.save(pd);
//		map.put("pd", pd);
//		map.put("result", errInfo);
//		return map;
//	}

	/**新增
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/add")
	// @RequiresPermissions("courseware:add")
	@ResponseBody
	@Transactional
	@LogAnno(menuType= "教育培训",menuServer= "在线学习与考试",instructionsOperate = "课件管理",instructionsType = "新增")
	public Object add() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		pd.put("VIDEOCOURSEWARE_ID", this.get32UUID());	//主键
		pd.put("CREATOR", Jurisdiction.getUsername());	//添加人
		pd.put("CREATTIME", DateUtil.date2Str(new Date()));	//添加时间
		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
		pd.put("ISDELETE", "0");	//是否删除(0:有效 1：删除)
		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
		pd.put("STATE", "0");	//课件状态 0启用、1禁用
		pd.put("TRAINTYPE", Jurisdiction.getCORPTRAINTYPE());//企业的培训行业类型
		pd.put("ISPLATFORM", "0");//是否是平台主键
		pd.put("VIDEOFILES", pd.get("videoId"));
		pd.put("ISPLATFORM", "0");
		Boolean getVideoInfo = false;
		//获取视频时长（每2秒访问一次阿里云，最多访问30次。）
		GetVideoInfoResponse response = null;
		for (int i = 0; i < 30; i++) {
			try {
				response = GetVideoInfo.getVideoInfo(pd);
			} catch (Exception e) {
				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
			}
			if(response.body.video.duration != null && 0.0 != response.body.video.duration) {
//				pd.put("VIDEOCAPTURE", response.body.video.coverURL.substring(0, response.body.video.coverURL.indexOf("?")));
				pd.put("VIDEOTIME", response.body.video.duration);
				Double videoTime = Double.valueOf(response.body.video.duration);
				pd.put("CLASSHOUR", Math.floor(videoTime / 60));
				getVideoInfo = true;
				break;
			}else {
				Thread.sleep(3000);
			}
		}
		if(getVideoInfo) {

			coursewareRelationService.saveByCourseware(pd,"1");//存储课件和字典的关系表
			videocoursewareService.save(pd);
			map.put("msg", "上传成功。");
			map.put("type", "success");
			try {
				DefaultAcsClient client = SubmitTrans.initVodClient();
				// 视频转码
				SubmitTrans.submitTranscodeJobs(client, pd);
			} catch (Exception e) {
				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
			}
		} else {
			map.put("msg", "视频上传失败，请稍后重试。");
			map.put("type", "warning");
		}
		map.put("pd", pd);
		map.put("result", errInfo);
		return map;
	}
	/**删除
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/delete")
	// @RequiresPermissions("courseware:del")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课件资源管理",instructionsType = "删除")
	public Object delete() throws Exception{
		Map<String,String> map = new HashMap<String,String>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		PageData d = videocoursewareService.findById(pd);
		smb.deleteFile(d.getString("VIDEOFILES"));
		smb.deleteFile(d.getString("VIDEOCAPTURE"));
		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
		String ArrayDATA_IDS[] = { pd.getString("VIDEOCOURSEWARE_ID") };
		pd.put("ArrayDATA_IDS", ArrayDATA_IDS);	//待删除ids
		pd.put("COURSEWARETYPE", "1");	//课件类型

		pd.put("CURRICULUM_ID", pd.getString("VIDEOCOURSEWARE_ID"));	//课件类型
		String count = kcmiddlekjService.countByCourseWareId(pd);
		if(!"0".equals(count)){
			map.put("result", "erroe");				//返回结果
			map.put("msg", "该课程已经在课件中发布！");
			return map;
		}
		coursewareRelationService.saveByCourseware(pd,"1");//存储课件和字典的关系表 没有添加的数据，所有可以当删除使用
		questionService.deleteByCoursewareIds(pd);
		videocoursewareService.delete(pd);
		map.put("result", errInfo);				//返回结果
		return map;
	}

//	/**修改((非阿里云，暂时废弃))
//	 * @param
//	 * @throws Exception
//	 */
//	@RequestMapping(value="/edit")
//	// @RequiresPermissions("courseware:edit")
//	@ResponseBody
//	public Object edit(@RequestParam(value="vfile",required=false) MultipartFile vfile,
//					   @RequestParam(value="vcfile",required=false) MultipartFile vcfile) throws Exception{
//		Map<String,Object> map = new HashMap<String,Object>();
//		String errInfo = "success";
//		PageData pd = new PageData();
//		pd = this.getPageData();
//		PageData d = videocoursewareService.findById(pd);
//		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
//		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
//		if (null != vfile ) {
//			String  ffile = DateUtil.getDays();
//			//本地
////			String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile;	//文件上传路径
////			String fileName = FileUpload.fileUp(file, filePath, this.get32UUID());				//执行上传
//			//服务器
//			String fileName = this.get32UUID()+vfile.getOriginalFilename().substring(vfile.getOriginalFilename().lastIndexOf("."));
//			smb.sshSftp(vfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
//			pd.put("VIDEOFILES", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
//			// 将MultipartFile file转换成为File
//			File f_file = FileUtil.MultipartFileToFile(vfile);
//			MultimediaObject instance = new MultimediaObject(f_file);
//			MultimediaInfo result = instance.getInfo();
//			System.out.println("视频时长："+result.getDuration());
//			double videoTime = (double)result.getDuration() / 1000.0;
//			pd.put("VIDEOTIME", videoTime+"");
//			f_file.delete();
//		}
//		if (null != vcfile) {
//			String  ffile = DateUtil.getDays();
//			//本地
////			String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile;	//文件上传路径
////			String fileName = FileUpload.fileUp(file, filePath, this.get32UUID());				//执行上传
//			//服务器
//			String fileName = this.get32UUID()+vcfile.getOriginalFilename().substring(vcfile.getOriginalFilename().lastIndexOf("."));
//			smb.sshSftp(vcfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
//			pd.put("VIDEOCAPTURE", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
//		}
//		videocoursewareService.edit(pd);
//		map.put("pd", pd);
//		map.put("result", errInfo);
//		return map;
//	}

	/**修改
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/edit")
	// @RequiresPermissions("courseware:edit")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课件资源管理",instructionsType = "修改")
	public Object edit() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		PageData d = videocoursewareService.findById(pd);
		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间

		if(pd != null && pd.get("isEditVideo") != null && Tools.notEmpty(pd.get("isEditVideo").toString()) && "true".equals(pd.get("isEditVideo").toString())) {
			pd.put("VIDEOFILES", pd.get("videoId"));
			Boolean getVideoInfo = false;
			//获取视频时长（每2秒访问一次阿里云，最多访问30次。）
			GetVideoInfoResponse response = null;
			for (int i = 0; i < 30; i++) {
				try {
					response = GetVideoInfo.getVideoInfo(pd);
				} catch (Exception e) {
					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
				}
				if(response.body.video.duration != null && 0.0 != response.body.video.duration) {
					//pd.put("VIDEOCAPTURE", response.body.video.coverURL.substring(0, response.body.video.coverURL.indexOf("?")));
					pd.put("VIDEOTIME", response.body.video.duration);
					Double videoTime = Double.valueOf(response.body.video.duration);
					pd.put("CLASSHOUR", Math.floor(videoTime / 60));
					getVideoInfo = true;
					break;
				}else {
					Thread.sleep(3000);
				}
			}
			if(getVideoInfo) {
				coursewareRelationService.saveByCourseware(pd,"1");//存储课件和字典的关系表
				videocoursewareService.edit(pd);
				map.put("msg", "上传成功。");
				map.put("type", "success");
				try {
					DefaultAcsClient client = SubmitTrans.initVodClient();
					// 视频转码
					SubmitTrans.submitTranscodeJobs(client, pd);
				} catch (Exception e) {
					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
				}
			} else {
				map.put("msg", "视频上传失败，请稍后重试。");
				map.put("type", "warning");
			}
		} else {
			coursewareRelationService.saveByCourseware(pd,"1");//存储课件和字典的关系表
			videocoursewareService.edit(pd);
			map.put("msg", "修改成功。");
			map.put("type", "success");
		}

		map.put("pd", pd);
		map.put("result", errInfo);
		return map;
	}

	/**列表
	 * @param page
	 * @throws Exception
	 */
	@RequestMapping(value="/list")
	// @RequiresPermissions("courseware:list")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课程管理",instructionsType = "视频课件列表")
	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());
		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
		page.setPd(pd);
		List<PageData>	varList = videocoursewareService.list(page);	//列出VideoCourseware列表
		map.put("varList", varList);
		map.put("page", page);
		map.put("result", errInfo);
		return map;
	}

	/**去修改页面获取数据
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/goEdit")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课程管理",instructionsType = "去修改页面获取数据")
	public Object goEdit() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		PageData video = videocoursewareService.findById(pd);	//根据ID读取
		if(video.get("VIDEOCOURSEWARE_ID_REMOTE") != null){//有远程ID 则获取远程auth
			PageData curriculum = curriculumService.findById(pd);
			PageData authPd = new PageData();
			authPd.put("VIDEOCOURSEWARE_ID",video.get("VIDEOCOURSEWARE_ID_REMOTE"));
			authPd.put("CURRICULUM_ID",curriculum.get("CURRICULUM_ID_REMOTE"));
			PageData playAuth = synchronizeInformationService.syncVideoPlayAuth(authPd);
			map.put("responseBody", playAuth.get("responseBody"));
			map.put("message", "获取成功。");
		}else {
			video.put("RECORD_ID", video.getString("VIDEOCOURSEWARE_ID"));
			Boolean getVideoInfo = false;
			//获取视频封面
			PageData vidData = new PageData();
			vidData.put("videoId", video.get("VIDEOFILES"));
			GetVideoInfoResponse response = null;
			response = GetVideoInfo.getVideoInfo(vidData);
			if (response.body.video.coverURL != null) {
				video.put("VIDEOCAPTURE", response.body.video.coverURL);
			}
		}
		List<PageData> coursewareAllList = coursewareRelationService.listAll(video);//课件字典关系信息，全部的信息
		map.put("pd", video);
		map.put("coursewareAllList", coursewareAllList);
		map.put("result", errInfo);
		return map;
	}

	/**获取视频播放地址
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/getVideoPlayAuth")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课件资源管理",instructionsType = "获取视频播放地址")
	public Object getVideoPlayAuth() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();

		GetTranscodeSummaryResponse tranRes = new GetTranscodeSummaryResponse();
		GetVideoPlayAuthResponse response = new GetVideoPlayAuthResponse();
		// 查看视频是否转码
		try {
			DefaultAcsClient client = SubmitTrans.initVodClient();
			tranRes = SubmitTrans.getTranscodeSummary(client, pd);
			// 转码中
			if (tranRes.getTranscodeSummaryList() != null && tranRes.getTranscodeSummaryList().size() > 0) {
				TranscodeSummary summary = tranRes.getTranscodeSummaryList().get(0);
				if(summary.getTranscodeStatus() != null && Tools.notEmpty(summary.getTranscodeStatus())) {
					if("Processing".equals(summary.getTranscodeStatus())) {
						map.put("msg", "视频正在转码请稍后再试。");
						map.put("type", "warning");
						return map;
					}
				}
			// 未转码，则进行视频转码，再提示用户转码中
			} else {
				try {
					// 视频转码
					SubmitTrans.submitTranscodeJobs(client, pd);
				} catch (Exception e) {
					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
				}
				map.put("msg", "视频正在转码请稍后再试。");
				map.put("type", "warning");
				return map;
			}

			response = AudioOrVideoCreateUpload.getVideoPlayAuth(pd);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if(response != null && response.body != null && response.body.playAuth != null) {
			map.put("msg", "获取成功。");
			map.put("type", "success");
			map.put("playAuth", response.body.playAuth);
		} else {
			map.put("msg", "视频获取失败，请稍后重试。");
			map.put("type", "warning");
		}
		map.put("result", errInfo);
		return map;
	}

	/**批量删除
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/deleteAll")
	// @RequiresPermissions("courseware:del")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课件资源管理",instructionsType = "批量删除")
	public Object deleteAll() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
		String DATA_IDS = pd.getString("DATA_IDS");
		if(Tools.notEmpty(DATA_IDS)){
			String ArrayDATA_IDS[] = DATA_IDS.split(",");
			pd.put("ArrayDATA_IDS", ArrayDATA_IDS);	//待删除ids
			List<PageData> pdList = videocoursewareService.findByIds(pd);
			for (PageData d : pdList) {
				smb.deleteFile(d.getString("VIDEOFILES"));
				smb.deleteFile(d.getString("VIDEOCAPTURE"));
			}
			pd.put("COURSEWARETYPE", "1");	//课件类型
			questionService.deleteByCoursewareIds(pd);
			videocoursewareService.deleteAll(pd);
			errInfo = "success";
		}else{
			errInfo = "error";
		}
		map.put("result", errInfo);				//返回结果
		return map;
	}

	/**导出到excel
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/excel")
	// @RequiresPermissions("toExcel")
	public ModelAndView exportExcel() throws Exception{
		ModelAndView mv = new ModelAndView();
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> dataMap = new HashMap<String,Object>();
		List<String> titles = new ArrayList<String>();
		titles.add("课件名称");	//1
		titles.add("主讲人");	//2
		titles.add("课件介绍");	//3
		titles.add("课件文件路径");	//4
		titles.add("课件截图");	//5
		titles.add("使用人员");	//6
		titles.add("添加人");	//7
		titles.add("添加时间");	//8
		titles.add("修改人");	//9
		titles.add("修改时间");	//10
		titles.add("是否删除(0:有效 1：删除)");	//11
		titles.add("企业ID");	//12
		dataMap.put("titles", titles);
		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
		List<PageData> varOList = videocoursewareService.listAll(pd);
		List<PageData> varList = new ArrayList<PageData>();
		for(int i=0;i<varOList.size();i++){
			PageData vpd = new PageData();
			vpd.put("var1", varOList.get(i).getString("COURSEWARENAME"));	    //1
			vpd.put("var2", varOList.get(i).getString("SPEAKER"));	    //2
			vpd.put("var3", varOList.get(i).getString("COURSEWAREINTRODUCE"));	    //3
			vpd.put("var4", varOList.get(i).getString("VIDEOFILES"));	    //4
			vpd.put("var5", varOList.get(i).getString("VIDEOCAPTURE"));	    //5
			vpd.put("var6", varOList.get(i).getString("VIDEOUSERS"));	    //6
			vpd.put("var7", varOList.get(i).getString("CREATOR"));	    //7
			vpd.put("var8", varOList.get(i).getString("CREATTIME"));	    //8
			vpd.put("var9", varOList.get(i).getString("OPERATOR"));	    //9
			vpd.put("var10", varOList.get(i).getString("OPERATTIME"));	    //10
			vpd.put("var11", varOList.get(i).get("ISDELETE").toString());	//11
			vpd.put("var12", varOList.get(i).getString("CORPINFO_ID"));	    //12
			varList.add(vpd);
		}
		dataMap.put("varList", varList);
		ObjectExcelView erv = new ObjectExcelView();
		mv = new ModelAndView(erv,dataMap);
		return mv;
	}

	/**列表
	 * @param page
	 * @throws Exception
	 */
	@RequestMapping(value="/getSelect")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课程管理",instructionsType = "列表")
	public Object getSelect(Page page) throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
		List<PageData>	varList = videocoursewareService.getSelect(pd);	//列出VideoCourseware列表
		map.put("list", varList);
		map.put("result", errInfo);
		return map;
	}
	/**修改
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/editState")
	// @RequiresPermissions("courseware:edit")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "在线学习与考试",instructionsOperate = "课件管理",instructionsType = "修改状态")
	public Object editState() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
		videocoursewareService.editByState(pd);
		map.put("result", errInfo);
		return map;
	}
}
