派生自 projectDept/qhighschool

EricsHu
2023-06-19 bc3b37b1622091def1f6ee4c3eb3ff79499b3466
src/main/java/com/qxueyou/scc/school/service/impl/ArticleService.java
@@ -39,7 +39,7 @@
import com.qxueyou.scc.teach.subject.model.SubjectChapter;
/**
 * 文章实现类
 * 文章实现类
 * 
 * @author zhiyong
 *
@@ -59,7 +59,7 @@
   @Autowired
   private ICourseWareService courseWareService;
   // 缓存
   // 缓存
   @SuppressWarnings("unused")
   private static final String CACHE_MSG_IMGS = "CACHE_MSG_IMGS_";
   @SuppressWarnings("unused")
@@ -71,7 +71,7 @@
   private static final int ONE_DAY = 60 * 60 * 24;
   /**
    * 查询列表数据
    * 查询列表数据
    * 
    * @param type
    * @return
@@ -87,7 +87,7 @@
   }
   /**
    * 新增或更新列表数据
    * 新增或更新列表数据
    * 
    * @param articleId
    * @param name
@@ -98,14 +98,14 @@
   public Result updateArticle(SchArticle article) {
      String articleId = article.getArticleId();
      if (StringUtils.isBlank(articleId)) {// 新增
      if (StringUtils.isBlank(articleId)) {// 新增
         article.setArticleId(null);
         article.setClassId(ClientUtils.getClassId());
         article.setOrgId(ClientUtils.getOrgId());
         article.setDeleteFlag(false);
         TraceUtils.setCreateTrace(article);
         // 序号
         // 序号
         String hql = "select MAX(c.orderNum) from SchArticle c where c.deleteFlag is false and c.classId= ? ";
         Integer iMax = this.findUnique(hql, CollectionUtils.newList(ClientUtils.getClassId()), Integer.class);
@@ -122,11 +122,11 @@
         this.saveArticle(article);
         articleId = article.getArticleId();
      } else {// 更新
      } else {// 更新
         SchArticle articleNew = this.read(SchArticle.class, articleId);
         // 原上传的文件url
         // 原上传的文件url
         String originUrl = articleNew.getUrl();
         articleNew.setCoverPageUrl(article.getCoverPageUrl());
@@ -138,23 +138,23 @@
         this.saveArticle(articleNew);
         // // 删除原上传的文件
         // // 删除原上传的文件
         // if(StringUtils.isNotBlank(originUrl)){
         // ossService.deleteOSSFile(originUrl.substring(1));
         // }
      }
      // 保存OrgText —— 文章内容
      // 保存OrgText —— 文章内容
      orgTextService.doSaveOrgText(articleId, OrgText.TABLE_NAME_ARTICLE, article.getContent());
      // 删除该班级所有缓存
      // 删除该班级所有缓存
      // new CacheUtils().deleteWBProjectCacheData();
      return new Result(true, "操作成功", articleId);
      return new Result(true, "操作成功", articleId);
   }
   /**
    * 新增或更新列表数据 机构
    * 新增或更新列表数据 机构
    * 
    * @return
    */
@@ -163,10 +163,10 @@
   public Result updateOrgArticle(SchArticle article, String collegeCourseId) {
      String articleId = article.getArticleId();
      // jgw 直接将文章修改为已发布
      // jgw 直接将文章修改为已发布
      article.setStatus(SchArticle.STATUS_PUBLISHED);
      if (StringUtils.isBlank(articleId)) {// 新增
      if (StringUtils.isBlank(articleId)) {// 新增
         article.setArticleId(null);
         article.setOrgId(ClientUtils.getOrgId());
         article.setDeleteFlag(false);
@@ -177,12 +177,12 @@
         this.saveArticle(article);
         articleId = article.getArticleId();
         // 保存文章课程关联关系
         // 保存文章课程关联关系
         saveSchArticleReCourse(collegeCourseId, article.getArticleId());
      } else {// 更新
      } else {// 更新
         SchArticle articleNew = this.read(SchArticle.class, articleId);
         // 原上传的文件url
         // 原上传的文件url
         String originUrl = articleNew.getUrl();
         articleNew.setCoverPageUrl(article.getCoverPageUrl());
@@ -194,23 +194,23 @@
         this.saveArticle(articleNew);
         // // 删除原上传的文件
         // // 删除原上传的文件
         // if(StringUtils.isNotBlank(originUrl)){
         // ossService.deleteOSSFile(originUrl.substring(1));
         // }
      }
      // 保存OrgText —— 文章内容
      // 保存OrgText —— 文章内容
      orgTextService.doSaveOrgText(articleId, OrgText.TABLE_NAME_ARTICLE, article.getContent());
      // 删除该班级所有缓存
      // 删除该班级所有缓存
      // new CacheUtils().deleteWBProjectCacheData();
      return new Result(true, "操作成功", articleId);
      return new Result(true, "操作成功", articleId);
   }
   /**
    * 保存文章课程关联关系
    * 保存文章课程关联关系
    * 
    * @param collegeCourseId
    * @param articleId
@@ -223,7 +223,7 @@
      course.setOrgId(ClientUtils.getOrgId());
      TraceUtils.setCreateTrace(course);
      // 序号
      // 序号
      String hql = "select MAX(c.orderNum) from SchArticleReCourse c where c.deleteFlag is false and c.collegeCourseId = ? and orgId = ? ";
      Integer iMax = this.findUnique(hql, CollectionUtils.newList(collegeCourseId, ClientUtils.getOrgId()),
            Integer.class);
@@ -240,7 +240,7 @@
   }
   /**
    * 删除文章
    * 删除文章
    * 
    * @param articleIds
    * @return
@@ -249,7 +249,7 @@
   public Result deleteArticle(String articleIds) {
      if (StringUtils.isBlank(articleIds)) {
         return new Result(false, "提交数据异常");
         return new Result(false, "提交数据异常");
      }
      String[] aIds = articleIds.split(",");
@@ -257,15 +257,15 @@
      this.bulkUpdateInLoop("update SchArticle set deleteFlag=1 where articleId=?", aIds);
      this.bulkUpdateInLoop("update SchCourseware set deleteFlag=1 where id=?", aIds);
      // 删除微商项目所有缓存
      // 删除微商项目所有缓存
      // new CacheUtils().deleteWBProjectCacheData();
      return new Result(true, "操作功能");
      return new Result(true, "操作功能");
   }
   /**
    * 
    * 查询基本信息
    * 查询基本信息
    * 
    * @param articleId
    * @return
@@ -285,11 +285,11 @@
      article.setCommentCount(this.findCount("from Comment where deleteFlag is false and commentObjectId = ?",
            CollectionUtils.newList(articleId)));
      article.setContent(content);
      return new Result(true, "查询成功", article);
      return new Result(true, "查询成功", article);
   }
   /**
    * 查询科目文章list
    * 查询科目文章list
    * 
    * @param collegeCourseId
    * @return
@@ -300,7 +300,7 @@
      List<Object> args = new ArrayList<Object>();
      String hql = "";
      // 其他
      // 其他
      if (("-" + collegeCourseId).equals(subjectId)) {
         hql = "select v.articleId,v.name,'','','',0,'' from SchArticle v,SchArticleReCourse r where v.collegeCourseId = ? and r.deleteFlag is false and r.articleId = v.articleId and v.deleteFlag is false and r.orgId = ?  "
               + "and not EXISTS (select 1 from SchSubject t where t.deleteFlag is false and t.subjectId = v.subjectId)";
@@ -342,11 +342,11 @@
   }
   /**
    * 排序
    * 排序
    */
   @Override
   public Result doitemOrder(List<String> ids, List<Integer> index) {
      // 循环修改order
      // 循环修改order
      for (int i = 0; i < ids.size(); i++) {
         String id = ids.get(i);
         if (UserInfoWrapper.ROLE_TEACHER.equals(ClientUtils.getCurrentRole())
@@ -361,14 +361,14 @@
               new Object[] { id });
      }
      // 删除微商项目所有缓存
      // 删除微商项目所有缓存
      // new CacheUtils().deleteWBProjectCacheData();
      return new Result(true, "修改成功");
      return new Result(true, "修改成功");
   }
   /**
    * 删除机构文章信息
    * 删除机构文章信息
    * 
    * @param articleIds
    * @param delAll
@@ -380,10 +380,10 @@
      for (String articleId : articleIds) {
         if ((orgIds != null && orgIds.length != 0) || (classIds != null && classIds.length != 0)) {
            // 删除需要回撤的讲义
            // 删除需要回撤的讲义
            deleteAppoint(articleId, orgIds, classIds);
         } else {
            // 删除讲义
            // 删除讲义
            String hql = " from SchArticleReCourse where articleId = ? and deleteFlag is false and orgId = ?";
            SchArticleReCourse shr = findUnique(hql, CollectionUtils.newList(articleId, ClientUtils.getOrgId()),
                  SchArticleReCourse.class);
@@ -399,7 +399,7 @@
             * null){ TraceUtils.setUpdateTrace(article); article.setDeleteFlag(true);
             * this.saveArticle(article); }
             */
            // 用户选择同时删除下级讲义
            // 用户选择同时删除下级讲义
            if (delAll == 1) {
               deleteSub(articleId, ClientUtils.getOrgId());
            }
@@ -407,12 +407,12 @@
      }
      return new Result(true, "删除成功");
      return new Result(true, "删除成功");
   }
   private Result deleteAppoint(String articleId, String orgIds[], String classIds[]) {
      Map<String, Object> args = new HashMap<String, Object>();
      // 删除需要回撤的机构讲义
      // 删除需要回撤的机构讲义
      if (orgIds.length != 0) {
         String hql = " from SchArticleReCourse where articleId = :articleId and deleteFlag is false and orgId in (:orgIds) and orgId != :currOrgId";
@@ -430,7 +430,7 @@
         }
      }
      // 删除需要回撤的班主任讲义
      // 删除需要回撤的班主任讲义
      if (classIds.length != 0) {
         args = new HashMap<String, Object>();
         args.put("articleId", articleId);
@@ -450,7 +450,7 @@
   @SuppressWarnings("unchecked")
   private void deleteSub(String articleId, String currOrgId) {
      // 机构层级视频是没有重新new ,查询出机构下级ID再删关联表
      // 机构层级视频是没有重新new ,查询出机构下级ID再删关联表
      String sql = " select oa.organization_id from organization as oa,organization ob " + " where "
            + " ob.ORGANIZATION_ID = ? " + " and  " + " oa.org_code like  CONCAT(ob.org_code,'%' ) "
            + " and oa.delete_flag is false and ob.delete_flag is false " + " order by oa.level,oa.org_code asc ";
@@ -468,7 +468,7 @@
         save(artCourse);
      }
      // 班主任层面视频指定过后都是new 出来的,通过originVideoId 可以查出所有指定过去的视频
      // 班主任层面视频指定过后都是new 出来的,通过originVideoId 可以查出所有指定过去的视频
      hql = "select classId from ClsClass where orgId in (:orgIds) and deleteFlag is false";
      map = new HashMap<String, Object>();
      map.put("orgIds", orgIds.toArray());
@@ -488,7 +488,7 @@
   }
   /**
    * 下发机构文件
    * 下发机构文件
    * 
    * @param articleId
    * @param orgId
@@ -500,9 +500,9 @@
   public Result insertAppointArticle(String[] articleIds, String[] orgIds, String[] classIds,
         String collegeCourseId) {
      if (null == articleIds || articleIds.length == 0) {
         return new Result(false, "参数错误");
         return new Result(false, "参数错误");
      }
      // 一次性查询classId对应的orgId
      // 一次性查询classId对应的orgId
      Map<String, Object> argsMap = new HashMap<String, Object>();
      Map<String, String> classMap = new HashMap<String, String>();
      if (classIds.length > 0) {
@@ -511,14 +511,14 @@
         argsMap.put("classIds", classIds);
         List<ClsClass> classList = findByComplexHql(hql, argsMap, ClsClass.class);
         // 放入map中 KEY:classId VALUE:orgId
         // 放入map中 KEY:classId VALUE:orgId
         for (ClsClass orgClass : classList) {
            classMap.put(orgClass.getClassId(), orgClass.getOrgId());
         }
      }
      // 一次性查出handoutId对应的handoutOrder
      // 一次性查出handoutId对应的handoutOrder
      Map<String, Integer> orderMap = new HashMap<String, Integer>();
      String hql = " from SchArticleReCourse where articleId in (:articleIds) and deleteFlag is false and orgId = :currOrgId";
      argsMap = new HashMap<String, Object>();
@@ -530,10 +530,10 @@
      }
      for (String articleId : articleIds) {
         if (orgIds.length > 0) { // 指定给机构
         if (orgIds.length > 0) { // 指定给机构
            insertAppointOrg(orgIds, articleId, collegeCourseId, orderMap);
         }
         if (classIds.length > 0) { // 指定给班级
         if (classIds.length > 0) { // 指定给班级
            insertAppointClass(classIds, articleId, collegeCourseId, orderMap);
         }
      }
@@ -542,7 +542,7 @@
   }
   /**
    * 指定给机构
    * 指定给机构
    * 
    * @param orgIds
    * @param handoutId
@@ -559,7 +559,7 @@
      for (String orgId : orgIds) {
         orgList.add(orgId);
      }
      // 剔除掉不符合条件的orgId
      // 剔除掉不符合条件的orgId
      orgList.removeAll(strings);
      if (orgList.isEmpty()) {
         return;
@@ -579,7 +579,7 @@
   }
   /**
    * 指定给班级
    * 指定给班级
    * 
    * @param classIds
    * @param handoutId
@@ -587,7 +587,7 @@
    */
   private void insertAppointClass(String classIds[], String articleId, String collegeCourseId,
         Map<String, Integer> orderMap) {
      // 章节id
      // 章节id
      Map<String, SubjectChapter> origChapterMap = new HashMap<String, SubjectChapter>();
      SchArticle article = read(SchArticle.class, articleId);
@@ -604,7 +604,7 @@
      if (classList.isEmpty()) {
         return;
      }
      // 一次性查询班级ID对应的classSubjectId
      // 一次性查询班级ID对应的classSubjectId
      hql = " from SchClassSubject where classId in(:classIds) and origSubjectId = :subjectId and deleteFlag is false";
      args = new HashMap<String, Object>();
      args.put("classIds", classList.toArray());
@@ -638,14 +638,14 @@
         TraceUtils.setCreateTrace(sh);
         this.saveArticle(sh);
         // 插入OrgText
         // 插入OrgText
         orgTextService.doInsertOrgText(sh.getArticleId(), OrgText.TABLE_NAME_ARTICLE,
               oldOrgText == null ? "" : oldOrgText.getContent());
      }
   }
   /**
    * 获取朋友圈
    * 获取朋友圈
    * 
    * @param pager
    * @return
@@ -710,7 +710,7 @@
   }
   /**
    * 获取消息的评论图片和文件
    * 获取消息的评论图片和文件
    * 
    * @param objSchClassCircleMsg
    * @return
@@ -748,7 +748,7 @@
   }
   /**
    * 点赞
    * 点赞
    * 
    * @param commentId
    * @return
@@ -774,7 +774,7 @@
   }
   /**
    * 评论
    * 评论
    * 
    * @param msgId
    * @param content
@@ -783,7 +783,7 @@
    */
   public Result addComment(String articleId, String content, String parentCommentId) {
      // 评论表
      // 评论表
      Comment comment = new Comment();
      comment.setCommentterId(ClientUtils.getUserId());
      comment.setCommentter(ClientUtils.getUserName());
@@ -815,7 +815,7 @@
   }
   /**
    * 删除评论
    * 删除评论
    * 
    * @param msgId
    * @param commentId
@@ -833,7 +833,7 @@
   }
   /**
    * 缓存获取评论
    * 缓存获取评论
    * 
    * @param articleId
    * @param isUpdate
@@ -856,7 +856,7 @@
   }
   /**
    * 评论列表
    * 评论列表
    * 
    * @param articleId
    * @return
@@ -866,7 +866,7 @@
   }
   /**
    * 观看进度
    * 观看进度
    * 
    * @param articleId
    * @param compDegree
@@ -900,7 +900,7 @@
   }
   /**
    * 保存文章接口
    * 保存文章接口
    * 
    * @param article
    * @return
@@ -927,7 +927,7 @@
         this.bulkUpdate("update SchCourseware set name = ? where id = ?",
               new Object[] { article.getName(), article.getArticleId() });
      }
      // 同步课件表
      // 同步课件表
      if (courseware == null) {
         courseware = new SchCourseware();
         courseware.setChapterId(article.getChapterId());