package com.zcloud.controller.platformCourseware;

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.DataCoursewareService;
import com.zcloud.service.courseware.QuestionService;
import com.zcloud.service.curriculum.KcmiddlekjService;
import com.zcloud.service.platformCourseware.PlatformCoursewareRecordService;
import com.zcloud.service.platformCourseware.PlatformDataCoursewareService;
import com.zcloud.service.platformCourseware.PlatformQuestionService;
import com.zcloud.service.platformRelation.PlatformCoursewareRelationService;
import com.zcloud.service.relation.CoursewareRelationService;
import com.zcloud.util.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;

/**
 * 说明：资料课件维护
 * 作者：luoxiaobao
 * 时间：2021-06-26
 * 官网：www.zcloudchina.com
 */
@Controller
@RequestMapping("/platform/datacourseware")
public class PlatformDataCoursewareController extends BaseController {

	@Autowired
	private DataCoursewareService datacoursewareService;
	@Autowired
	private QuestionService questionService;
	@Autowired
	private KcmiddlekjService kcmiddlekjService;
	@Autowired
	private PlatformDataCoursewareService platformDataCoursewareService;
	@Autowired
	private PlatformCoursewareRecordService platformCoursewareRecordService;
	@Autowired
	private PlatformQuestionService platformQuestionService;
	@Autowired
	private PlatformCoursewareRelationService platformCoursewareRelationService;
	@Autowired
	private CoursewareRelationService coursewareRelationService;
	@Autowired
	private Smb smb;
	/**新增
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/add")
	// @RequiresPermissions("courseware:add")
	@ResponseBody
	public Object add(@RequestParam(value="cfile",required=false) MultipartFile cfile,
					  @RequestParam(value="ccfile",required=false) MultipartFile ccfile) throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		pd.put("DATACOURSEWARE_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");	//企业ID
		pd.put("TRAINTYPE", Jurisdiction.getCORPTRAINTYPE());//企业的培训行业类型
		if (null != cfile && !cfile.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()+cfile.getOriginalFilename().substring(cfile.getOriginalFilename().lastIndexOf("."));
			smb.sshSftp(cfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
			pd.put("COURSEWAREFILES", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
		}
		if (null != ccfile && !ccfile.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()+ccfile.getOriginalFilename().substring(ccfile.getOriginalFilename().lastIndexOf("."));
			smb.sshSftp(ccfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
			pd.put("COURSEWARECAPTURE", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
		}
		datacoursewareService.save(pd);
		map.put("pd", pd);
		map.put("result", errInfo);
		return map;
	}

	/**删除
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/delete")
	// @RequiresPermissions("courseware:del")
	@ResponseBody
	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 = datacoursewareService.findById(pd);
		smb.deleteFile(d.getString("COURSEWAREFILES"));
		smb.deleteFile(d.getString("COURSEWARECAPTURE"));
		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", "2");	//课件类型
		pd.put("CURRICULUM_ID", pd.getString("DATACOURSEWARE_ID"));	//课件类型
		String count = kcmiddlekjService.countByCourseWareId(pd);
		if(!"0".equals(count)){
			map.put("result", "erroe");				//返回结果
			map.put("msg", "该课程已经在课件中发布！");
			return map;
		}
		questionService.deleteByCoursewareIds(pd);
		datacoursewareService.delete(pd);
		map.put("result", errInfo);				//返回结果
		return map;
	}

	/**修改
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/edit")
	// @RequiresPermissions("courseware:edit")
	@ResponseBody
	public Object edit(@RequestParam(value="cfile",required=false) MultipartFile cfile,
					   @RequestParam(value="ccfile",required=false) MultipartFile ccfile) throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();

		PageData d = datacoursewareService.findById(pd);
		//已经不修改了，还删附件是什么意思
//		smb.deleteFile(d.getString("COURSEWAREFILES"));
//		smb.deleteFile(d.getString("COURSEWARECAPTURE"));
		pd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
		pd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
		if (null != cfile ) {
			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()+cfile.getOriginalFilename().substring(cfile.getOriginalFilename().lastIndexOf("."));
			smb.sshSftp(cfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
			pd.put("COURSEWAREFILES", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
		}
		if (null != ccfile) {
			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()+ccfile.getOriginalFilename().substring(ccfile.getOriginalFilename().lastIndexOf("."));
			smb.sshSftp(ccfile, fileName, Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile);
			pd.put("COURSEWARECAPTURE", Const.FILEPATHFILE + Jurisdiction.getCORPINFO_ID() + "/" + ffile + "/" + fileName);
		}
		datacoursewareService.edit(pd);
		map.put("pd", pd);
		map.put("result", errInfo);
		return map;
	}

//	/**列表
//	 * @param page
//	 * @throws Exception
//	 */
//	@RequestMapping(value="/list")
//	// @RequiresPermissions("courseware: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());
//		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
//		page.setPd(pd);
//		List<PageData>	varList = datacoursewareService.list(page);	//列出DataCourseware列表
//		map.put("varList", varList);
//		map.put("page", page);
//		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());
		pd.put("TRAINTYPE", Jurisdiction.getCORPTRAINTYPE());
		page.setPd(pd);
		List<PageData>	varList = platformDataCoursewareService.listByCorpinfo(page);	//列出datacoursewareCorpInfoRecord列表
		map.put("varList", varList);
		map.put("page", page);
		map.put("result", errInfo);
		return map;
	}

	/**去修改页面获取数据
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/goEdit")
	@ResponseBody
	public Object goEdit() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		pd = datacoursewareService.findById(pd);	//根据ID读取
		map.put("pd", pd);
		map.put("result", errInfo);
		return map;
	}

	/**批量删除
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/deleteAll")
	// @RequiresPermissions("courseware:del")
	@ResponseBody
	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 = datacoursewareService.findByIds(pd);
			for (PageData d : pdList) {
				smb.deleteFile(d.getString("COURSEWAREFILES"));
				smb.deleteFile(d.getString("COURSEWARECAPTURE"));
			}
			pd.put("COURSEWARETYPE", "2");	//课件类型
			questionService.deleteByCoursewareIds(pd);
			datacoursewareService.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 = datacoursewareService.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("COURSEWAREFILES"));	    //4
			vpd.put("var5", varOList.get(i).getString("COURSEWARECAPTURE"));	    //5
			vpd.put("var6", varOList.get(i).getString("COURSEWAREUSERS"));	    //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
	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 = datacoursewareService.getSelect(pd);	//列出DataCourseware列表
		map.put("list", varList);
		map.put("result", errInfo);
		return map;
	}

	/**列表（全部视频课件+资料课件）
	 * @param page
	 * @throws Exception
	 */
	@RequestMapping(value="/getAllCourseware")
	@ResponseBody
	public Object getAllCourseware(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 = datacoursewareService.getAllCourseware(pd);	//列出DataCourseware列表
		map.put("list", varList);
		map.put("result", errInfo);
		return map;
	}
	/**修改
	 * @param
	 * @throws Exception
	 */
	@RequestMapping(value="/editState")
	// @RequiresPermissions("courseware:edit")
	@ResponseBody
	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()));	//修改时间
		datacoursewareService.editByState(pd);
		map.put("result", errInfo);
		return map;
	}


	/** 把平台资源加入到我的课件中
	 * @param page
	 * @throws Exception
	 */
	@RequestMapping(value="/joinMyCourseware")
	// @RequiresPermissions("courseware:list")
	@ResponseBody
	@LogAnno(menuType= "教育培训",menuServer= "平台资源库",instructionsOperate = "课件资源管理",instructionsType = "把平台资源加入到我的课件中")
	public Object joinMyCourseware() throws Exception{
		Map<String,Object> map = new HashMap<String,Object>();
		String errInfo = "success";
		PageData pd = new PageData();
		pd = this.getPageData();
		String corpInfoID = Jurisdiction.getCORPINFO_ID();
		String userID = Jurisdiction.getUSER_ID();
		if(Tools.isEmpty(pd.getString("COURSEWARE_ID"))){
			errInfo = "failure";
			map.put("result", errInfo);
			map.put("msg", "参数错误！请联系管理员");
			return map;
		}
		pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
		pd.put("CREATOR", Jurisdiction.getUSER_ID());
		pd.put("OPERATOR", Jurisdiction.getUSER_ID());
		pd.put("CREATORNAME", Jurisdiction.getUsername());
		pd.put("OPERATORNAME", Jurisdiction.getUsername());
		pd.put("TYPE", "1");
//		String url = "/purchase/joinMyCourseware";
//		Object [] params =  new Object[]{"coursewareID","corpInfoID","userID"}; // 参数名
//		Object [] values =new Object[]{coursewareId,corpInfoID,userID}; // 参数值
//		List<NameValuePair> paramsList = HttpClientService.getParams(params, values); // 获取参数对象
//		/**
//		 * 发送post
//		 */
//		Object result2 = HttpClientService.sendPost(url, paramsList);
//		JSONObject jSONObject = JSONObject.parseObject(result2.toString());
//		if(Tools.isEmpty(jSONObject.get("result"))){ // 返回信息失败
//			errInfo = "failure";
//			map.put("result", errInfo);
//			map.put("msg", "添加失败！请联系管理员");
//			return map;
//		}
//		if(!"success".equals(jSONObject.getString("result"))){ //返回信息提示错误
//			errInfo = "failure";
//			map.put("result", errInfo);
//			map.put("msg", jSONObject.get("msg"));
//			return map;
//		}
//		JSONObject valMap = JSONObject.parseObject(jSONObject.get("pd").toString()); // 返回的对象
		// 新增课件信息
		PageData corpCou = addCourse(pd);
		// 购买记录
		purchaseCourseware(pd,corpCou.getString("DATACOURSEWARE_ID"));
		//习题
		pd.put("COURSEWAREID", pd.getString("COURSEWARE_ID"));
		List<PageData> questionList =  platformQuestionService.listByCouId(pd);
		// 新增课件下习题信息
		if(questionList != null && questionList.size() > 0) {
			Integer max = 0;
			for(PageData question : questionList) {
				question.put("QUESTION_ID", this.get32UUID());	//主键
				question.put("COURSEWAREID", corpCou.getString("DATACOURSEWARE_ID"));	//主键
				question.put("CREATOR", Jurisdiction.getUsername());	//添加人
				question.put("CREATTIME", DateUtil.date2Str(new Date()));	//添加时间
				question.put("OPERATOR", Jurisdiction.getUsername());	//修改人
				question.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
				question.put("ISDELETE", "0");	//是否删除(0:有效 1：删除)
				question.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
				max ++;
				question.put("QUESTIONNUMBER",max); //题号
				question.put("ISPLATFORMPAPER", "0");
				questionService.save(question);
			}
		}



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

	/**
	 * 购买课件
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public void purchaseCourseware(PageData pd, String corpCouId) throws Exception{


//		Double PRICE = 1d;
//		if(!Tools.isEmpty(plaCou.get("PRICE"))){
//			PRICE = Double.parseDouble(plaCou.get("PRICE").toString());
//		}

//		if(0d != PRICE){
//			errInfo = "failure";
//			map.put("pd", "");
//			map.put("msg", "添加失败！该产品暂时不能添加！");
//			map.put("result", errInfo);
//		}

		/** 添加企业购买记录 开始 **/
		PageData record = new PageData();
		record.put("RECORD_ID",this.get32UUID());
		record.put("COURSEWARE_ID",pd.getString("COURSEWARE_ID"));
		record.put("CORPINFO_ID",pd.get("CORPINFO_ID"));
		record.put("CREATOR",pd.get("CREATOR"));
		record.put("CREATTIME",DateUtil.date2Str(new Date()));
		record.put("OPERATOR",pd.get("OPERATOR"));
		record.put("OPERATTIME",DateUtil.date2Str(new Date()));
		record.put("CREATORNAME",pd.get("CREATORNAME"));
		record.put("OPERATORNAME",pd.get("OPERATORNAME"));
		record.put("CORP_COURSEWARE_ID",corpCouId);
		record.put("TYPE","2");
		record.put("PATTERN","1");
		platformCoursewareRecordService.save(record);
		/** 添加企业购买记录 结束 **/
	}

	/**
	 * 新增课件信息
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public PageData addCourse(PageData pd) throws Exception{
		pd.put("DATACOURSEWARE_ID", pd.getString("COURSEWARE_ID"));
		PageData course = new PageData();
		course = platformDataCoursewareService.findById(pd);


		pd.put("RECORD_ID",pd.getString("DATACOURSEWARE_ID"));
		List<PageData> coursewareAllList = platformCoursewareRelationService.listAll(pd);//课件字典关系信息，全部的信息
		PageData addPd = new PageData();
		addPd.put("PLATFORMID",  course.get("DATACOURSEWARE_ID"));
		addPd.put("DATACOURSEWARE_ID", this.get32UUID());	//主键 平台主键
		addPd.put("COURSEWARENAME", course.get("COURSEWARENAME"));	//课件名称
		addPd.put("SPEAKER", course.get("SPEAKERNAME"));	//主讲人
		addPd.put("COURSEWAREINTRODUCE", course.get("COURSEWAREINTRODUCE"));	//课件介绍
		addPd.put("COURSEWAREFILES", course.get("COURSEWAREFILES"));	//课件文件路径
		addPd.put("COURSEWARECAPTURE", course.get("COURSEWARECAPTURE"));	//课件截图

		addPd.put("COURSEWAREUSERS", course.get("COURSEWAREUSERS"));	//视频课件时长(秒)
		addPd.put("CREATOR", Jurisdiction.getUsername());	//添加人
		addPd.put("CREATTIME",  course.get("CREATTIME"));	//添加时间 平台创建时间
		addPd.put("OPERATOR", Jurisdiction.getUsername());	//修改人
		addPd.put("OPERATTIME", DateUtil.date2Str(new Date()));	//修改时间
		addPd.put("ISDELETE", "0");	//是否删除(0:有效 1：删除)
		addPd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());	//企业ID
		addPd.put("STATE", "0");	//课件状态 0启用、1禁用

		addPd.put("TRAINTYPE", Jurisdiction.getCORPTRAINTYPE());//企业的培训行业类型
		addPd.put("POSTTYPE",  course.get("POSTTYPE"));//岗位培训类型
		addPd.put("ONTLINETYPE",  course.get("ONTLINETYPE"));//岗位培训类型
		addPd.put("CLASSHOUR",  course.get("CLASSHOUR"));//课时，单位分鐘
		addPd.put("ONTLINETYPE",  course.get("ONTLINETYPE"));//岗位培训类型
		addPd.put("ISPLATFORM",  "1");//是否未平台
		datacoursewareService.save(addPd);
		if(coursewareAllList != null && coursewareAllList.size() > 0) {
			for(PageData relation : coursewareAllList) {
				relation.put("COURSEWARERELATION_ID", UuidUtil.get32UUID());
				relation.put("RECORD_ID", addPd.get("DATACOURSEWARE_ID"));
				coursewareRelationService.save(relation);
			}
		}
		return addPd;
	}
}
