package com.qxueyou.scc.courseware.action;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.qxueyou.scc.admin.classes.model.ClsClass;
|
import com.qxueyou.scc.admin.classes.service.IClassService;
|
import com.qxueyou.scc.base.dao.CommonDAO;
|
import com.qxueyou.scc.base.model.Constants;
|
import com.qxueyou.scc.base.model.Pager;
|
import com.qxueyou.scc.base.model.Result;
|
import com.qxueyou.scc.base.service.ICommonService;
|
import com.qxueyou.scc.base.util.ClientUtils;
|
import com.qxueyou.scc.base.util.CollectionUtils;
|
import com.qxueyou.scc.base.util.TraceUtils;
|
import com.qxueyou.scc.base.util.WordProcessUtils;
|
import com.qxueyou.scc.courseware.service.ICourceCategoryService;
|
import com.qxueyou.scc.exercise.model.ExerciseReCourse;
|
import com.qxueyou.scc.media.model.MediaVideoReCourse;
|
import com.qxueyou.scc.org.model.OrgCategoryLevel;
|
import com.qxueyou.scc.org.model.OrgCollegeCourse;
|
import com.qxueyou.scc.org.model.OrgCourse;
|
import com.qxueyou.scc.org.model.OrgCourseCategory;
|
import com.qxueyou.scc.org.model.Organization;
|
import com.qxueyou.scc.school.model.SchHandoutReCourse;
|
|
/**
|
* ¿ÆÄ¿Àà±ð¹ÜÀícontroller
|
*
|
* @author µÂ»¢
|
* @history 2014-11-25 н¨ Ïĵ»¢
|
*
|
*/
|
@Controller
|
@RequestMapping(value = "/org/courcecategory")
|
public class CourceCategoryController {
|
|
@Autowired
|
private CommonDAO commonDAO;
|
|
@Autowired
|
@Qualifier("commonAppService")
|
ICommonService commonService;
|
|
@Autowired
|
private ICourceCategoryService categoryService;
|
|
@SuppressWarnings("unused")
|
@Autowired
|
private IClassService orgClassService;
|
|
/*@Autowired
|
ISysBusinessCacheService sysBusinessCacheService ;*/
|
|
/**
|
* APP2.0: ¿Î³Ì³¬ÊÐ Ñ¡¿Î »ñÈ¡ËùÓзÖÀà <br>
|
* URL /org/courcecategory/courseCatNew<br>
|
*
|
* @method GET
|
* @return ·µ»ØÖµJSON´®:<br>
|
*
|
* <pre>
|
* [{"index":1,"code":"1CKJR","categoryName":"²Æ»á½ðÈÚ","categoryId":"18","imgPath":"/web/res/img/app/coursemarket_ico_accounting.png"},
|
* ......
|
* {"index":8,"code":"9QB","categoryName":"È«²¿","categoryId":"26","imgPath":"/web/res/img/app/coursemarket_ico_classify.png"}]
|
* </pre>
|
*
|
* ×Ö¶Îֵ˵Ã÷:
|
*
|
* <pre>
|
* index:Ë÷Òý
|
* code:±àÂë
|
* categoryName:Ãû×Ö
|
* categoryId:id
|
* imgPath:logo URL
|
* </pre>
|
*/
|
@RequestMapping(value = "courseCatNew", method = RequestMethod.GET)
|
public @ResponseBody List<Map<String, Object>> getCourseCatData() {
|
|
Pager page = new Pager();
|
page.setPageNum(1);
|
page.setPageSize(Integer.MAX_VALUE);
|
|
// 1. ²éѯ¸Ã»ú¹¹ÏÂËùÓеĿÆÄ¿
|
String hql = "select c from OrgCourseCategory c where c.deleteFlag is false and c.categoryLevel = ? order by c.code asc ";
|
|
List<OrgCourseCategory> lstLastCategory = commonDAO.findList(hql, page, CollectionUtils.newList(OrgCourseCategory.CATEGORY_LEVEL_FIRST), OrgCourseCategory.class);
|
|
if (lstLastCategory.isEmpty()) {
|
return new ArrayList<Map<String, Object>>();
|
}
|
|
List<Map<String, Object>> lstMap = new ArrayList<Map<String, Object>>(lstLastCategory.size());
|
Map<String, Object> map;
|
Map<String, Object> QBMap = new HashMap<String, Object>(5);
|
|
int index = 0;
|
for (OrgCourseCategory courseCat : lstLastCategory) {
|
|
if ("0QB".equals(courseCat.getCode())) {
|
QBMap.put("index", 8);
|
QBMap.put("categoryId", courseCat.getCategoryId());
|
QBMap.put("categoryName", courseCat.getCategoryName());
|
QBMap.put("code", courseCat.getCode());
|
QBMap.put("imgPath", courseCat.getImgPath());
|
if (StringUtils.isNotBlank(courseCat.getImgPath()) && !"null".equals(courseCat.getImgPath())) {
|
QBMap.put("imgPathShade", courseCat.getImgPath().split("\\.")[0].concat("-shade.png"));
|
} else {
|
QBMap.put("imgPathShade", courseCat.getImgPath());
|
}
|
} else if (!"8QT".equals(courseCat.getCode())) {
|
index = index + 1;
|
map = new HashMap<String, Object>(5);
|
map.put("index", index);
|
map.put("categoryId", courseCat.getCategoryId());
|
map.put("categoryName", courseCat.getCategoryName());
|
map.put("code", courseCat.getCode());
|
map.put("imgPath", courseCat.getImgPath());
|
if (StringUtils.isNotBlank(courseCat.getImgPath()) && !"null".equals(courseCat.getImgPath())) {
|
map.put("imgPathShade", courseCat.getImgPath().split("\\.")[0].concat("-shade.png"));
|
} else {
|
map.put("imgPathShade", courseCat.getImgPath());
|
}
|
lstMap.add(map);
|
}
|
|
}
|
lstMap.add(QBMap);
|
|
return lstMap;
|
}
|
|
/**
|
* APP2.0: ¿Î³Ì³¬ÊÐ ËùÓвéѯÌõ¼þ <br>
|
* URL /org/courcecategory/courseCatContitionNew<br>
|
*
|
* ·µ»ØÖµJSON´®:<br>
|
*
|
* <pre>
|
* {
|
* "course":[
|
* {"code":"0QB","children":[],"index":1,"categoryName":"È«²¿","categoryId":"26","parentId":null},
|
* {"code":"1CKJR","children":[],"index":2,"categoryName":"²Æ»á½ðÈÚ","categoryId":"18","parentId":null},
|
* {"code":"2YYKS","children":[],"index":3,"categoryName":"ÓïÑÔ¿¼ÊÔ","categoryId":"19","parentId":null},
|
* {"code":"3YYL","children":[],"index":4,"categoryName":"Ò½Ò©Àà","categoryId":"20","parentId":null},
|
* {"code":"4JGL","children":[],"index":5,"categoryName":"½¨¹¤Àà","categoryId":"21","parentId":null},
|
* {"code":"5ZYKZ","children":null,"index":6,"categoryName":"Ö°Òµ¿¼Ö¤","categoryId":"22","parentId":null},
|
* {"code":"6XLJY","children":[
|
* {"code":null,"index":1,"categoryName":"¾¼Ãѧ","categoryId":"5","parentId":"23"},
|
* {"code":null,"index":2,"categoryName":"·¨Ñ§","categoryId":"6","parentId":"23"}
|
* ],"index":7,"categoryName":"ѧÀú½ÌÓý","categoryId":"23","parentId":null},
|
* {"code":"7ITJN","children":[],"index":8,"categoryName":"IT¼¼ÄÜ","categoryId":"24","parentId":null},
|
* {"code":"8QT","children":[],"index":9,"categoryName":"ÆäËû","categoryId":"25","parentId":null}
|
* ],
|
* "city":[{"name":"ÉîÛÚ","index":1,"code":"sz"},{"name":"¹ãÖÝ","index":2,"code":"gz"}],
|
* "sort":[{"name":"¼Û¸ñÓɵ͵½¸ß","index":1,"code":"PRICE_ASC"},{"name":"¼Û¸ñÓɸߵ½µÍ","index":2,"code":"PRICE_DESC"}]
|
* }
|
*
|
* <pre>
|
*
|
* @return
|
*/
|
@RequestMapping(value = "courseCatContitionNew", method = RequestMethod.GET)
|
public @ResponseBody Map<String, Object> getCourseCatContitionData() {
|
return categoryService.generateAllCourseCondition();
|
}
|
|
/**
|
* APP2.0: ¸Ã»ú¹¹ÏÂËùÓпγ̵ķÖÀàºÍ¿ÆÄ¿ URL: /org/courcecategory/courseCategoryNew
|
*
|
* @return
|
*/
|
@Deprecated
|
@RequestMapping(value = "courseCategoryNew", method = RequestMethod.GET)
|
public @ResponseBody List<OrgCourseCategory> getCourseCategoryData() {
|
|
// 1. ²éѯ¸Ã»ú¹¹ÏÂËùÓеĿÆÄ¿
|
String hql = "select courseId,name,price,imgPath,courseCategoryId " + " from OrgCourse c where c.deleteFlag is false";
|
|
// 2. ²éѯ¸Ã»ú¹¹ÏÂËùÓеĿÆÄ¿¶ÔÓ¦µÄÀà±ð
|
String hql_type = "select distinct c.category.categoryId,c.category.categoryName from OrgCourse c where " + " c.deleteFlag is false order by c.createTime ";
|
|
List<Object> args = new ArrayList<Object>(1);
|
// Èç¹ûÊÇÓÎ¿Í°à ²éËùÓлú¹¹ 1:±íʾÓοͰà
|
// if (!orgClassService.isCurrentVistorClass()) {
|
// hql = hql.concat(" and c.org.organizationId=?");
|
// hql_type = "select distinct c.category.categoryId,c.category.categoryName from OrgCourse c where " + " c.org.organizationId=? and c.deleteFlag is false order by c.createTime ";
|
// args = CollectionUtils.newList(ClientUtils.getOrgId());
|
// }
|
|
// 1. ²éѯ¸Ã»ú¹¹ÏÂËùÓеĿÆÄ¿
|
List<OrgCollegeCourse> lstCourse = categoryService.queryOrgCourseListNew(hql, args);
|
|
// 2. ²éѯ¸Ã»ú¹¹ÏÂËùÓеĿÆÄ¿¶ÔÓ¦µÄÀà±ð
|
List<OrgCourseCategory> lstCategory = categoryService.queryOrgCourseCategoryList(hql_type, args);
|
|
// ×é×°½á¹¹
|
List<OrgCollegeCourse> newLstCourse = null;
|
for (OrgCourseCategory category : lstCategory) {
|
newLstCourse = new ArrayList<OrgCollegeCourse>();
|
for (OrgCollegeCourse course : lstCourse) {
|
if (category.getCategoryId().equals(course.getCourseCategoryId())) {
|
newLstCourse.add(course);
|
}
|
}
|
category.setCourseList(newLstCourse);
|
}
|
// ²»ÏÞÖÆÖµ
|
String not_limit = Constants.NOT_LIMIT_VALUE;
|
// ÖØÐÂ×é×°ÀàÐÍ Ìí¼Ó²»ÏÞ
|
List<OrgCourseCategory> lstLastCategory = new ArrayList<OrgCourseCategory>();
|
// Ìí¼ÓµÚÒ»¸ö²»ÏÞ
|
OrgCourseCategory category = new OrgCourseCategory();
|
category.setCategoryId(not_limit);
|
category.setCategoryName("²»ÏÞ");
|
|
List<OrgCollegeCourse> lstLastCourse = new ArrayList<OrgCollegeCourse>();
|
OrgCollegeCourse course = new OrgCollegeCourse();
|
course.setCourseId(not_limit);
|
course.setName("²»ÏÞ");
|
|
lstLastCategory.add(category);
|
lstLastCategory.addAll(lstCategory);
|
|
for (OrgCourseCategory cate : lstLastCategory) {
|
lstLastCourse = new ArrayList<OrgCollegeCourse>();
|
lstLastCourse.add(course);
|
if (not_limit.equals(cate.getCategoryId())) {// ²»ÏÞ
|
lstLastCourse.addAll(lstCourse);
|
} else {
|
lstLastCourse.addAll(cate.getCourseList());
|
}
|
|
cate.setCourseList(lstLastCourse);
|
}
|
|
return lstLastCategory;
|
}
|
|
/******************************************************************* ÉÏÃæÎªApp½Ó¿Ú£¬ÏÂÃæÎªºǫ́½Ó¿Ú **************************/
|
|
/**
|
* ¿ÆÄ¿Àà±ðÁбí
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
public @ResponseBody List<OrgCourseCategory> list() {
|
Organization org = commonDAO.read(Organization.class, ClientUtils.getOrgId());
|
|
return commonDAO.find("from OrgCourseCategory where deleteFlag is false and categoryLevel = ? and type = ?", CollectionUtils.newList(OrgCourseCategory.CATEGORY_LEVEL_SECOND, org.getType()), OrgCourseCategory.class);
|
}
|
|
/**
|
* ¸ù¾Ý¿ÆÄ¿ID²éѯ¿ÆÄ¿
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/{courceTypeId}", method = RequestMethod.GET)
|
public String get(@PathVariable String courceTypeId) {
|
// TODO
|
return null;
|
}
|
|
/**
|
* ÐÂÔö
|
*
|
* @return
|
*/
|
@RequestMapping(method = RequestMethod.POST)
|
public String add() {
|
// TODO
|
return null;
|
}
|
|
/**
|
* ɾ³ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/{courceTypeId}", method = RequestMethod.DELETE)
|
public String delete(@PathVariable String courceTypeId) {
|
// TODO
|
return null;
|
}
|
|
/**
|
* ¸üÐÂ
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/{courceTypeId}", method = RequestMethod.POST)
|
public String update(@PathVariable String courceTypeId) {
|
// TODO
|
return null;
|
}
|
|
/**
|
* ÐÂÔöÀà±ð²ã¼¶
|
*
|
* @return
|
*/
|
|
|
|
@RequestMapping(value = "/addCategory", method = RequestMethod.POST)
|
public @ResponseBody Result addCategory(String id, String name, String code, String type) {
|
|
Result result = categoryService.addCategory(null, id, name, code, type);
|
|
if(result.isSuccess()){
|
return result;
|
}
|
|
return new Result(false,"²ÎÊý´íÎó");
|
|
}
|
|
/**
|
* Àà±ð²ã¼¶Êý¾Ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/allData", method = RequestMethod.POST)
|
public @ResponseBody List<OrgCategoryLevel> allData() {
|
String hql = " from OrgCategoryLevel where deleteFlag is false and topOrgId = ? order by orderNum desc, createTime asc";
|
Organization org = commonDAO.read(Organization.class, ClientUtils.getOrgId());
|
List<OrgCategoryLevel> lstCate = commonDAO.find(hql, CollectionUtils.newList(org.getTopOrganizationId()), OrgCategoryLevel.class);
|
List<String> levelIds = new ArrayList<String>();
|
for (OrgCategoryLevel orgCategoryLevel : lstCate) {
|
levelIds.add(orgCategoryLevel.getCategoryLevelId());
|
}
|
if(levelIds.isEmpty()){
|
return lstCate;
|
}
|
Map<String,Object> args = new HashMap<String, Object>();
|
args.put("levelIds", levelIds.toArray());
|
hql = "from OrgCollegeCourse where deleteFlag is false and courseCategoryId in (:levelIds) order by code asc";
|
List<OrgCollegeCourse> courses = commonDAO.findByComplexHql(hql, args, OrgCollegeCourse.class);
|
Map<String,List<OrgCollegeCourse>> map = new HashMap<String, List<OrgCollegeCourse>>();
|
for (OrgCollegeCourse orgCollegeCourse : courses) {
|
if(null == orgCollegeCourse){
|
continue;
|
}
|
//È¥³ýµô²»contentÄÚÈÝ
|
orgCollegeCourse.setContent("");
|
|
if(null == map.get(orgCollegeCourse.getCourseCategoryId())){
|
List<OrgCollegeCourse> lstCourse = new ArrayList<OrgCollegeCourse>();
|
lstCourse.add(orgCollegeCourse);
|
map.put(orgCollegeCourse.getCourseCategoryId(), lstCourse);
|
}else{
|
map.get(orgCollegeCourse.getCourseCategoryId()).add(orgCollegeCourse);
|
}
|
}
|
for (OrgCategoryLevel orgCategoryLevel : lstCate) {
|
|
orgCategoryLevel.setCourses(map.get(orgCategoryLevel.getCategoryLevelId()));
|
}
|
return lstCate;
|
}
|
|
/**
|
* ÊÓÆµÀà±ð²ã¼¶Êý¾Ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/allCountData", method = RequestMethod.POST)
|
public @ResponseBody List<OrgCategoryLevel> allCountData() {
|
return setCount(1);
|
}
|
|
/**
|
* ½²ÒåÀà±ð²ã¼¶Êý¾Ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/allHandoutCountData", method = RequestMethod.POST)
|
public @ResponseBody List<OrgCategoryLevel> allHandoutCountData() {
|
return setCount(2);
|
}
|
|
/**
|
* Á·Ï°Àà±ð²ã¼¶Êý¾Ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/allExerciseCountData", method = RequestMethod.POST)
|
public @ResponseBody List<OrgCategoryLevel> allExersiseCountData() {
|
return setCount(3);
|
}
|
|
/**
|
* ½²ÒåÀà±ð²ã¼¶Êý¾Ý
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/allArticleCountData", method = RequestMethod.POST)
|
public @ResponseBody List<OrgCategoryLevel> allArticleCountData() {
|
return setCount(4);
|
}
|
|
/**
|
* ²éѯÊÓÆµ½²ÒåÁ·Ï°ÔÚ¸÷¸ö¿ÆÄ¿ÏµÄÊýÁ¿
|
* @param type 1:ÊÓÆµ 2£º½²Òå 3£ºÁ·Ï°
|
* @return
|
*/
|
@SuppressWarnings("unchecked")
|
private List<OrgCategoryLevel> setCount(int type){
|
String hql = " from OrgCategoryLevel where deleteFlag is false and topOrgId = ? order by level asc, code asc";
|
Organization org = commonDAO.read(Organization.class, ClientUtils.getOrgId());
|
List<OrgCategoryLevel> lstCate = commonDAO.find(hql, CollectionUtils.newList(org.getTopOrganizationId()), OrgCategoryLevel.class);
|
String sql = "";
|
switch (type) {
|
case 1:
|
sql = "select r.college_course_id,count(1) from media_video_re_course r, media_video v where r.delete_flag is false and r.org_id = ? and v.video_id = r.video_id and v.delete_flag is false group by college_course_id " ;
|
break;
|
case 2:
|
sql = "select r.college_course_id,count(1) from sch_handout_re_course r, sch_handout v where r.delete_flag is false and r.org_id = ? and v.handout_id = r.handout_id and v.delete_flag is false group by college_course_id" ;
|
break;
|
case 3:
|
sql = "select r.college_course_id,count(1) from exercise_re_course r where r.delete_flag is false and r.org_id = ? group by college_course_id" ;
|
break;
|
case 4:
|
sql = "select r.college_course_id,count(1) from sch_article_re_course r, sch_article v where r.delete_flag is false and r.org_id = ? and v.ARTICLE_ID = r.ARTICLE_ID and v.delete_flag is false group by college_course_id" ;
|
break;
|
default:
|
break;
|
}
|
List<Object[]> lst = this.commonDAO.findBySql(sql, CollectionUtils.newList(ClientUtils.getOrgId()));
|
|
Map<String,Integer> map = new HashMap<String,Integer>(5);
|
for (Object[] obj : lst) {
|
map.put(String.valueOf(obj[0]), Integer.parseInt(String.valueOf(obj[1])));
|
}
|
|
for (OrgCategoryLevel orgCategoryLevel : lstCate) {
|
hql = "from OrgCollegeCourse where deleteFlag is false and courseCategoryId = ? order by code asc";
|
List<OrgCollegeCourse> courses = commonDAO.find(hql, CollectionUtils.newList(orgCategoryLevel.getCategoryLevelId()), OrgCollegeCourse.class);
|
|
for(OrgCollegeCourse course : courses){
|
if(type==1){
|
course.setVideoCount(null != map.get(course.getCollegeCourseId()) ? map.get(course.getCollegeCourseId()) : 0);
|
}else if(type==2){
|
course.setHandoutCount(null != map.get(course.getCollegeCourseId()) ? map.get(course.getCollegeCourseId()) : 0);
|
}else if(type==3){
|
course.setGroupCount(null != map.get(course.getCollegeCourseId()) ? map.get(course.getCollegeCourseId()) : 0);
|
}else if(type==4){
|
course.setArticleCount(null != map.get(course.getCollegeCourseId()) ? map.get(course.getCollegeCourseId()) : 0);
|
}
|
course.setContent(null);
|
}
|
orgCategoryLevel.setCourses(courses);
|
}
|
|
return lstCate;
|
}
|
|
/**
|
* ztree²ã¼¶Êý¾Ý
|
*
|
* @return
|
*//*
|
@RequestMapping(value = "/allHierarchyData", method = RequestMethod.POST)
|
public @ResponseBody List<OrgCourseCategory> allHierarchyData() {
|
|
return sysBusinessCacheService.getOrgCourseCategory();
|
|
}
|
|
*//**
|
* ztree²ã¼¶Êý¾Ý
|
*
|
* @return
|
*//*
|
@RequestMapping(value = "live/allHierarchyData", method = RequestMethod.POST)
|
public @ResponseBody ResultJson allLiveHierarchyData() {
|
|
return sysBusinessCacheService.getLiveOrgCourseCategory();
|
|
}*/
|
|
/**
|
* ²éѯ
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/oneMsg", method = RequestMethod.POST)
|
public @ResponseBody OrgCategoryLevel oneMsg(String id) {
|
String hql = "from OrgCategoryLevel where deleteFlag is false and categoryLevelId = ?";
|
|
return commonDAO.findUnique(hql, CollectionUtils.newList(id), OrgCategoryLevel.class);
|
}
|
|
/**
|
* ²éѯרҵÐÅÏ¢
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/oneCourse", method = RequestMethod.POST)
|
public @ResponseBody Result oneCourse(String id) {
|
String hql = "from OrgCollegeCourse where deleteFlag is false and collegeCourseId = ?";
|
OrgCollegeCourse occ = commonDAO.findUnique(hql, CollectionUtils.newList(id), OrgCollegeCourse.class);
|
|
Map<String,Object> data = new HashMap<String,Object>();
|
data.put("name", occ.getName());
|
data.put("content", occ.getContent());
|
data.put("price", occ.getPrice());
|
data.put("courseId", occ.getCourseId());
|
data.put("collegeCourseId", occ.getCollegeCourseId());
|
data.put("relation","");
|
Result result = new Result(true,null,data);
|
|
hql = " from OrgCourse where deleteFlag is false and courseId = ?";
|
OrgCourse course = commonDAO.findUnique(hql, CollectionUtils.newList(occ.getCourseId()), OrgCourse.class);
|
if(null == course){
|
return result;
|
}
|
|
hql = " from OrgCourseCategory where deleteFlag is false and categoryId = ?";
|
OrgCourseCategory cates = commonDAO.findUnique(hql, CollectionUtils.newList(course.getCourseCategoryId()), OrgCourseCategory.class);
|
|
StringBuffer sb = new StringBuffer(course.getName()).append('/');
|
sb.insert(0, cates.getCategoryName()+"/");
|
int i = 0;
|
while(cates.getCategoryLevel()==OrgCourseCategory.CATEGORY_LEVEL_FIRST){
|
i++;
|
hql = " from OrgCourseCategory where deleteFlag is false and categoryId = ?";
|
cates = commonDAO.findUnique(hql, CollectionUtils.newList(cates.getParentCategoryId()),OrgCourseCategory.class);
|
if(cates==null){
|
break;
|
}
|
sb.insert(0,cates.getCategoryName()+"/");
|
if(i==10){
|
break;
|
}
|
}
|
if(sb.length()!=0){
|
data.put("relation",sb.deleteCharAt(sb.length()-1).toString() );
|
}
|
|
return result;
|
}
|
|
/**
|
* »ñÈ¡»ú¹¹Ãû×Ö
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/getOrgName", method = RequestMethod.POST)
|
public @ResponseBody Result getOrgName() {
|
Organization org = commonDAO.read(Organization.class, ClientUtils.getOrgId());
|
|
return new Result(true, org.getName());
|
}
|
|
/**
|
* ɾ³ý¿ÆÄ¿
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/deleteCate", method = RequestMethod.POST)
|
public @ResponseBody Result deleteCate(String id) {
|
|
return categoryService.doDeleteCate(id);
|
}
|
|
/**
|
* ɾ³ýרҵ
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/deleteCourse", method = RequestMethod.POST)
|
public @ResponseBody Result deleteCourse(String id) {
|
|
return categoryService.doDeleteCourse(id);
|
}
|
|
/**
|
* 3³õʼ»¯¿ÆÄ¿
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/initCourse", method = RequestMethod.POST)
|
public @ResponseBody Result initCourse() {
|
String hql = " from OrgCollegeCourse where deleteFlag is false ";
|
List<OrgCollegeCourse> lstCourse = commonDAO.find(hql, OrgCollegeCourse.class);
|
int i = 0;
|
|
/*for (OrgCollegeCourse orgCollegeCourse : lstCourse) {
|
Organization org = commonDAO.read(Organization.class, orgCollegeCourse.getOrganizationId());
|
hql = " from OrgCourseCategory where deleteFlag is false and categoryLevel !=? and type = ? and categoryType = ?";
|
OrgCourseCategory c = commonDAO.findUnique(hql, CollectionUtils.newList(OrgCourseCategory.CATEGORY_LEVEL_FIRST,org.getType(),orgCollegeCourse.getType()), OrgCourseCategory.class);
|
if(c!=null){
|
orgCollegeCourse.setCourseCategoryId(c.getCategoryId());
|
orgCollegeCourse.setCourseCategoryName(c.getCategoryName());
|
}
|
|
}*/
|
Map<String,Object> map = new HashMap<String, Object>();
|
Map<String,Object> courseMap = new HashMap<String, Object>();
|
for (OrgCollegeCourse orgCollegeCourse : lstCourse) {
|
Organization org = commonDAO.read(Organization.class, orgCollegeCourse.getOrganizationId());
|
hql = " from OrgCourseCategory where categoryId = ? and deleteFlag is false";
|
OrgCourseCategory cate = commonDAO.findUnique(hql, CollectionUtils.newList(orgCollegeCourse.getCourseCategoryId()), OrgCourseCategory.class);
|
if(cate==null){
|
continue;
|
}
|
//hql = " from OrgCategoryLevel where topOrgId = ? and categoryName = ? and deleteFlag is false";
|
//OrgCategoryLevel level = commonDAO.findUnique(hql,CollectionUtils.newList(orgCollegeCourse.getTopOrgId(),cate.getCategoryName()),OrgCategoryLevel.class);
|
OrgCategoryLevel level = (OrgCategoryLevel) map.get(org.getTopOrganizationId()+"-"+cate.getCategoryName());
|
if(level==null){
|
level = new OrgCategoryLevel();
|
level.setCategoryName(cate.getCategoryName());
|
level.setCode(cate.getCode());
|
level.setDeleteFlag(false);
|
level.setFullName(cate.getFullName());
|
level.setImgPath(cate.getImgPath());
|
level.setLevel(BigDecimal.ONE.shortValue());
|
level.setParentId(null);
|
level.setOrgId(orgCollegeCourse.getOrganizationId());
|
level.setTopOrgId(org.getTopOrganizationId());
|
TraceUtils.setCreateTrace(level);
|
commonService.save(level);
|
map.put(org.getTopOrganizationId()+"-"+cate.getCategoryName(), level);
|
}
|
|
//hql = " from OrgCollegeCourse where deleteFlag is false and topOrgId = ? and courseId = ?";
|
//OrgCollegeCourse oc = commonDAO.findUnique(hql, CollectionUtils.newList(org.getTopOrganizationId(),orgCollegeCourse.getCourseId()), OrgCollegeCourse.class);
|
OrgCollegeCourse oc = (OrgCollegeCourse) courseMap.get(org.getTopOrganizationId()+"-"+orgCollegeCourse.getCourseId());
|
if(oc==null){
|
orgCollegeCourse.setTopOrgId(org.getTopOrganizationId());
|
orgCollegeCourse.setCourseCategoryId(level.getCategoryLevelId());
|
orgCollegeCourse.setCourseCategoryName(level.getCategoryName());
|
commonService.save(orgCollegeCourse);
|
courseMap.put(org.getTopOrganizationId()+"-"+orgCollegeCourse.getCourseId(), orgCollegeCourse);
|
}
|
|
i++;
|
}
|
return new Result(true,"×ܹ²ÓÐ"+lstCourse.size()+",³õʼ»¯ÁË"+i+"Ìõ");
|
}
|
|
/**
|
* 2Ïȳõʼ»¯¿Î¼þÊý¾Ý£¬ÔÙ³õʼ»¯ÉÏÃæµÄ¿ÆÄ¿
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/initCourseWare", method = RequestMethod.POST)
|
public @ResponseBody Result initCourseWare() {
|
|
//ÊÓÆµ
|
int i = 0;
|
String hql = " from MediaVideoReCourse where deleteFlag is false";
|
List<MediaVideoReCourse> videos = commonDAO.find(hql, MediaVideoReCourse.class);
|
for (MediaVideoReCourse course : videos) {
|
hql = " from OrgCollegeCourse where collegeCourseId = ? and deleteFlag is false";
|
OrgCollegeCourse oc = commonDAO.findUnique(hql, CollectionUtils.newList(course.getCollegeCourseId()), OrgCollegeCourse.class);
|
if(oc==null){
|
continue;
|
}
|
course.setOrgId(oc.getOrganizationId());
|
TraceUtils.setUpdateTrace(course);
|
commonService.save(course);
|
i++;
|
}
|
//½²Òå
|
int y = 0;
|
hql = " from SchHandoutReCourse where deleteFlag is false";
|
List<SchHandoutReCourse> handouts = commonDAO.find(hql, SchHandoutReCourse.class);
|
for (SchHandoutReCourse course : handouts) {
|
hql = " from OrgCollegeCourse where collegeCourseId = ? and deleteFlag is false";
|
OrgCollegeCourse oc = commonDAO.findUnique(hql, CollectionUtils.newList(course.getCollegeCourseId()), OrgCollegeCourse.class);
|
if(oc==null){
|
continue;
|
}
|
course.setOrgId(oc.getOrganizationId());
|
TraceUtils.setUpdateTrace(course);
|
commonService.save(course);
|
y++;
|
}
|
//Á·Ï°
|
int z = 0;
|
hql = " from ExerciseReCourse where deleteFlag is false";
|
List<ExerciseReCourse> exers = commonDAO.find(hql, ExerciseReCourse.class);
|
for (ExerciseReCourse course : exers) {
|
hql = " from OrgCollegeCourse where collegeCourseId = ? and deleteFlag is false";
|
OrgCollegeCourse oc = commonDAO.findUnique(hql, CollectionUtils.newList(course.getCollegeCourseId()), OrgCollegeCourse.class);
|
if(oc==null){
|
continue;
|
}
|
course.setOrgId(oc.getOrganizationId());
|
TraceUtils.setUpdateTrace(course);
|
commonService.save(course);
|
z++;
|
}
|
return new Result(true,"ÊÓÆµ×ܹ²"+videos.size()+"¸ö,³É¹¦ÁË"+i+"¸ö"+"½²Òå×ܹ²"+handouts.size()+"¸ö,³É¹¦ÁË"+y+"¸ö"+"Á·Ï°×ܹ²"+exers.size()+"¸ö,³É¹¦ÁË"+z+"¸ö");
|
}
|
|
/**
|
* 1³õʼ»¯°à¼¶ »ú¹¹ID
|
*
|
* @return
|
*/
|
@RequestMapping(value = "/initClass", method = RequestMethod.POST)
|
public @ResponseBody Result initClass() {
|
String hql = " from ClsClass where deleteFlag is false ";
|
List<ClsClass> ocs = commonDAO.find(hql, ClsClass.class);
|
int i = 0;
|
for (ClsClass orgClass : ocs) {
|
hql = " from OrgCollegeCourse where collegeCourseId = ? and deleteFlag is false";
|
OrgCollegeCourse course = commonDAO.findUnique(hql,CollectionUtils.newList(orgClass.getCollegeCourseId()), OrgCollegeCourse.class);
|
if(course==null){
|
continue;
|
}
|
hql = " from Organization where organizationId = ? and deleteFlag is false";
|
Organization org = commonDAO.findUnique(hql, CollectionUtils.newList(course.getOrganizationId()), Organization.class);
|
if(org==null){
|
continue;
|
}
|
orgClass.setOrgId(org.getOrganizationId());
|
TraceUtils.setUpdateTrace(orgClass);
|
commonService.save(orgClass);
|
i++;
|
}
|
return new Result(true,"°à¼¶×ܹ²"+ocs.size()+",³É¹¦ÁË"+i+"¸ö");
|
}
|
|
/**
|
* ³õʼ»¯levelCode
|
*
|
* @return
|
*/
|
@SuppressWarnings("unused")
|
@RequestMapping(value = "/initLevel", method = RequestMethod.GET)
|
public @ResponseBody Result initLevel() {
|
String hql = " from OrgCategoryLevel where deleteFlag is false and level = ?";
|
// List<OrgCategoryLevel> parentsFirst = commonDAO.find(hql, CollectionUtils.newList(OrgCategoryLevel.CATEGORY_LEVEL_FIRST), OrgCategoryLevel.class);
|
// for (OrgCategoryLevel orgCategoryLevel : parentsFirst) {
|
// if(StringUtils.isBlank(orgCategoryLevel.getCategoryName())||StringUtils.isNotBlank(orgCategoryLevel.getLevelCode())){
|
// continue;
|
// }
|
// String levelCode = generateLevelCode(orgCategoryLevel.getCategoryName());
|
// String code = cacheService.get("course1_"+levelCode, String.class);
|
// if(code==null){
|
// orgCategoryLevel.setLevelCode(levelCode+"_00");
|
// commonService.save(orgCategoryLevel);
|
// cacheService.set("course1_"+levelCode, 24*60*60, orgCategoryLevel.getCategoryLevelId());
|
// continue;
|
// }else{
|
// int i = 0;
|
// String lc = "";
|
// do{
|
// i++;
|
// lc = levelCode+i;
|
// }while(null!=cacheService.get("course1_"+levelCode+i, String.class));
|
// orgCategoryLevel.setLevelCode(lc+"_00");
|
// commonService.save(orgCategoryLevel);
|
// cacheService.set("course1_"+lc, 24*60*60, orgCategoryLevel.getCategoryLevelId());
|
// continue;
|
// }
|
//
|
// }
|
//
|
initNextLevel(Short.parseShort("2"));
|
initNextLevel(Short.parseShort("3"));
|
initNextLevel(Short.parseShort("4"));
|
initNextLevel(Short.parseShort("5"));
|
initNextLevel(Short.parseShort("6"));
|
initNextLevel(Short.parseShort("7"));
|
initNextLevel(Short.parseShort("8"));
|
initNextLevel(Short.parseShort("9"));
|
initNextLevel(Short.parseShort("10"));
|
|
return new Result(true);
|
}
|
|
@SuppressWarnings("unused")
|
private void initNextLevel(short level){
|
String hql = " from OrgCategoryLevel where deleteFlag is false and level = ?";
|
List<OrgCategoryLevel> parentsSecond = commonDAO.find(hql, CollectionUtils.newList(level), OrgCategoryLevel.class);
|
for (OrgCategoryLevel orgCategoryLevel : parentsSecond) {
|
if(StringUtils.isNotBlank(orgCategoryLevel.getLevelCode())){
|
continue;
|
}
|
|
OrgCategoryLevel parent = commonDAO.read(OrgCategoryLevel.class, orgCategoryLevel.getParentId());
|
if(null==parent||StringUtils.isBlank(parent.getLevelCode())){
|
continue;
|
}
|
String levelCode = parent.getLevelCode()+"00";
|
// String code = cacheService.get("course1_"+levelCode, String.class);
|
String code = null;
|
if(code==null){
|
orgCategoryLevel.setLevelCode(levelCode);
|
commonService.save(orgCategoryLevel);
|
// cacheService.set("course1_"+levelCode, 24*60*60, orgCategoryLevel.getCategoryLevelId());
|
continue;
|
}else{
|
int i = 0;
|
String lc = "";
|
do{
|
i++;
|
String h = String.valueOf(i);
|
if(i<10){
|
h = "0"+i;
|
}
|
lc = parent.getLevelCode()+h;
|
// }while(null!=cacheService.get("course1_"+lc, String.class));
|
}while(true);
|
// orgCategoryLevel.setLevelCode(lc);
|
// commonService.save(orgCategoryLevel);
|
// cacheService.set("course1_"+lc, 24*60*60, orgCategoryLevel.getCategoryLevelId());
|
// continue;
|
}
|
|
}
|
}
|
|
|
@SuppressWarnings("unused")
|
private String generateLevelCode(String name) {
|
|
// תƴÒô
|
//ʹÓÃ΢Èí×Ô´øÖÐÎÄÊäÈë·¨ÓÃÊó±ê·Ò³£¬Ñ¡ÔñµÚÒ»Ò³Ö®ºóµÄÊý¾Ýʱ£¬»áÉú³É(li'zhi.dr)ÕâÖÖÕ˺Å
|
String[] arrUnidecode = WordProcessUtils.toPinyin(name.replace(" ",""), " ").replaceAll("'", "").split(" ");
|
|
String orgCode = "";
|
if(null != arrUnidecode){
|
for(String str : arrUnidecode){
|
orgCode = orgCode.concat(str.substring(0,1));
|
}
|
}
|
|
|
return orgCode;
|
}
|
|
public static void main(String[] args) {
|
String[] arrUnidecode = WordProcessUtils.toPinyin("22".replace(" ","")).replaceAll("'", "").split(" ");
|
String orgCode = "";
|
if(null != arrUnidecode){
|
for(String str : arrUnidecode){
|
orgCode = orgCode.concat(str.substring(0,1));
|
}
|
}
|
System.out.println(orgCode);
|
}
|
|
}
|