派生自 projectDept/qhighschool

EricsHu
2022-12-05 068fc7f2e81178e55fa191a13709af64b1a163f6
src/main/java/com/qxueyou/scc/school/service/impl/HandoutService.java
@@ -87,9 +87,9 @@
import com.jacob.com.Variant;
/**
 * 讲义管理服务
 * 讲义管理服务
 * 
 * @author 德虎 2015-1-4
 * @author 德虎 2015-1-4
 *
 */
@Service
@@ -122,7 +122,7 @@
   @Autowired
   IOrgTextService orgTextService;
   // /** 极光推送替换信鸽 */
   // /** 极光推送替换信鸽 */
   // @Autowired
   // IJPushService jpushService;
@@ -139,7 +139,7 @@
   private ICourseWareService courseWareService;
   /**
    * 依赖注入
    * 依赖注入
    *
    * @param handoutDAO
    */
@@ -149,7 +149,7 @@
   }
   /**
    * PPT\PPTX (office文件不直接处理,发送消息,使用特定的文档处理服务器处理) PDF直接处理
    * PPT\PPTX (office文件不直接处理,发送消息,使用特定的文档处理服务器处理) PDF直接处理
    * 
    * 
    */
@@ -157,23 +157,23 @@
   public Result insertHandout(String fullPath, String module, SchHandout handout) {
      File file = null;
      try {
         // 取得当前上传文件类型:office(ppt、pptx)或者pdf,直接用后缀名来判断格式(office还是pdf)
         // 取得当前上传文件类型:office(ppt、pptx)或者pdf,直接用后缀名来判断格式(office还是pdf)
         String filePart[] = fullPath.split("\\.");
         String fileType = filePart[filePart.length - 1];
         // 1.下载到应用服务器本地
         // 1.下载到应用服务器本地
         String uuid = UUIDUtils.generateUUID();
         String filePath = HandoutService.class.getClassLoader().getResource("../uploads").getPath()
               .concat("handout/" + uuid + "/" + uuid + "." + fileType);
         file = fileUploadService.doGetOssFile(fullPath, filePath, module, ClientUtils.getUserId());
         // 是否是office
         // 是否是office
         boolean pptFlag = false;
         if ("PPT".equals(fileType.toUpperCase()) || "PPTX".equals(fileType.toUpperCase())) {
            // 如果有密码,返回前台提示 07+ 无打开密码有权限密码无法检测出来
            // 如果有密码,返回前台提示 07+ 无打开密码有权限密码无法检测出来
            if (getDecryptFlag(file, fileType.toUpperCase())) {
               return new Result(false, "导入失败:您提交的文件有密码,请上传没有密码的文件!");
               return new Result(false, "导入失败:您提交的文件有密码,请上传没有密码的文件!");
            }
            pptFlag = true;
         }
@@ -190,13 +190,13 @@
         this.saveHandout(handout);
         handout.setOriginHandoutId(handout.getHandoutId());
         // 保存OrgText —— 讲义详情
         // 保存OrgText —— 讲义详情
         orgTextService.doSaveOrgText(handout.getHandoutId(), OrgText.TABLE_NAME_HANDOUT, handout.getRemark());
         // 更新上传文件使用轨迹
         // 更新上传文件使用轨迹
         fileUploadService.updateUploadTrace(fullPath, module, SysFileUploadTrace.FILE_USE, handout.getHandoutId());
         // 序号
         // 序号
         String hql = "select MAX(c.orderNum) from SchHandout c where c.deleteFlag is false and c.classId = ? ";
         Integer iMax = this.findUnique(hql, CollectionUtils.newList(ClientUtils.getClassId()), Integer.class);
@@ -208,7 +208,7 @@
         handout.setOrderNum(iMax);
         this.saveHandout(handout);
         // 标记班级有讲义
         // 标记班级有讲义
         ClsClass cls = read(ClsClass.class, ClientUtils.getClassId());
         if (cls != null && cls.getHaveHandout() == ClsClass.NOT_HAVE_HANDOUT) {
            cls.setHaveHandout(ClsClass.HAVE_HANDOUT);
@@ -219,10 +219,10 @@
         result.addData("pptFlag", pptFlag);
         return result;
      } catch (Exception e) {
         this.log.error("讲义转码失败" + fullPath, e);
         this.log.error("讲义转码失败" + fullPath, e);
      } finally {
         if (file != null) {
            // 删除下载到应用服务器的文档
            // 删除下载到应用服务器的文档
            fileUploadService.doDeleteTempOssFile(file.getParentFile(), module, ClientUtils.getUserId());
         }
      }
@@ -230,7 +230,7 @@
   }
   /**
    * 转码PDF发送消息
    * 转码PDF发送消息
    * 
    * @param handoutId
    * @param fullPath
@@ -268,7 +268,7 @@
      } catch (Exception e) {
         String businessId = aliOnsConfig.getCommonTopic() + "-" + UUIDUtils.generateUUID();
         String desp = "handoutId:" + handoutId + ";fullPath:" + fullPath + ";module:" + module;
         log.error(businessId + " :转码PDF讲义失败:" + e, e);
         log.error(businessId + " :转码PDF讲义失败:" + e, e);
      }
   }
@@ -280,15 +280,15 @@
      } catch (Exception e) {
         String desp = "handoutId:" + handoutId + ";docPath:" + docPath + ";uploadModule:" + uploadModule;
         log.error(handoutId + " :上传讲义ppt消息发送失败:" + e, e);
         log.error(handoutId + " :上传讲义ppt消息发送失败:" + e, e);
      }
   }
   /**
    * docdeal 消息队列调用,将office文件从oss下载到web server上,解析成图片,将解析后的图片传到oss上
    * 20150915:正式环境出现同一个ppt解析了两份,(消息队列处理前删除前面内容,用最新内容,这样操作,收藏的讲义可能会出现问题),已处理过不处理
    * 修改bug:ppt和jpg当前不在同一个目录下面,修改到同一个目录下面
    * docdeal 消息队列调用,将office文件从oss下载到web server上,解析成图片,将解析后的图片传到oss上
    * 20150915:正式环境出现同一个ppt解析了两份,(消息队列处理前删除前面内容,用最新内容,这样操作,收藏的讲义可能会出现问题),已处理过不处理
    * 修改bug:ppt和jpg当前不在同一个目录下面,修改到同一个目录下面
    * 
    * @param docPath
    * @param handoutId
@@ -333,7 +333,7 @@
         // uploadModule, userId);
         // 2.deal doc
         // 使用新方式解析讲义,有个缺陷:上传img及数据库中handoutpage默认排序(15页ppt为例):1,10,11,12,13,14,15,2,3,4,5,6,7,8,9
         // 使用新方式解析讲义,有个缺陷:上传img及数据库中handoutpage默认排序(15页ppt为例):1,10,11,12,13,14,15,2,3,4,5,6,7,8,9
         List<SchHandoutPage> lstPages = Collections.EMPTY_LIST;
         if ("PPT".equals(type)) {
            lstPages = this.convertPPTToJPG(objOfficeFile, docPath, handoutId);
@@ -344,14 +344,14 @@
         // 3.insert pages
         if (lstPages.isEmpty()) {
            log.error("转换ppt为空:" + handoutId + "-" + docPath + "-" + userId + "-" + uploadModule);
            log.error("转换ppt为空:" + handoutId + "-" + docPath + "-" + userId + "-" + uploadModule);
            // 4.modify handout status and pageCount
            SchHandout objHandout = this.read(SchHandout.class, handoutId);
            // jgw ,直接修改为发布
            // jgw ,直接修改为发布
            objHandout.setStatus(SchHandout.STATUS_FAILURE);
            this.saveHandout(objHandout);
            return new Result(false, "office讲义转换失败");
            return new Result(false, "office讲义转换失败");
         }
         for (SchHandoutPage page : lstPages) {
            page.setHandoutId(handoutId);
@@ -361,23 +361,23 @@
         // 4.modify handout status and pageCount
         SchHandout objHandout = this.read(SchHandout.class, handoutId);
         objHandout.setPageCount(lstPages.size());
         // jgw ,直接修改为发布
         // jgw ,直接修改为发布
         objHandout.setStatus(SchHandout.STATUS_ISSUED);
         // 如果首页图片为null 并且 lstPages不为空
         // 如果首页图片为null 并且 lstPages不为空
         if (StringUtils.isBlank(objHandout.getCoverPageUrl())) {
            objHandout.setCoverPageUrl(lstPages.get(0).getImgPath());
         }
         this.saveHandout(objHandout);
         // 如果是管理员上传,处理指定到别处的数据
         // 如果是管理员上传,处理指定到别处的数据
         doInitClassHandout(objHandout, lstPages);
         log.debug("end1...docDealMsgReceiveService call insertHandoutPages success: docPath:  " + docPath
               + " ;handoutId:  " + handoutId);
      } catch (Exception e) {
         log.error("调用docdeal服务器解析ppt失败,失败原因:" + handoutId, e);
         log.error("调用docdeal服务器解析ppt失败,失败原因:" + handoutId, e);
         SchHandout objHandout = this.read(SchHandout.class, handoutId);
         if (null != objHandout) {
            objHandout.setStatus(SchHandout.STATUS_FAILURE);
@@ -393,7 +393,7 @@
   }
   /**
    * PPT\PPTX (office文件不直接处理,发送消息,使用特定的文档处理服务器处理) PDF直接处理
    * PPT\PPTX (office文件不直接处理,发送消息,使用特定的文档处理服务器处理) PDF直接处理
    * 
    * 
    */
@@ -402,26 +402,26 @@
   public Result insertOrgHandout(String fullPath, String module, SchHandout handout, String collegeCourseId) {
      File file = null;
      try {
         // 取得当前上传文件类型:office(ppt、pptx)或者pdf,直接用后缀名来判断格式(office还是pdf)
         // 取得当前上传文件类型:office(ppt、pptx)或者pdf,直接用后缀名来判断格式(office还是pdf)
         String filePart[] = fullPath.split("\\.");
         String fileType = filePart[filePart.length - 1];
         String rootPath = sccConfig.getResRootPath();
         String outputPath = rootPath.concat(filePart[0].substring(1, filePart[0].length()));
         // 1.下载到应用服务器本地
         // 1.下载到应用服务器本地
         file = fileUploadService.doGetOssFile(fullPath,
               "/temp/uploads/handout/" + UUIDUtils.generateUUID() + "/" + fileType + "." + fileType, module,
               ClientUtils.getUserId());
         // 是否是office
         // 是否是office
         boolean pptFlag = false;
         if ("PPT".equals(fileType.toUpperCase()) || "PPTX".equals(fileType.toUpperCase())) {
            // 如果有密码,返回前台提示 07+ 无打开密码有权限密码无法检测出来
            // 如果有密码,返回前台提示 07+ 无打开密码有权限密码无法检测出来
            if (getDecryptFlag(file, fileType.toUpperCase())) {
               return new Result(false, "导入失败:您提交的文件有密码,请上传没有密码的文件!");
               return new Result(false, "导入失败:您提交的文件有密码,请上传没有密码的文件!");
            }
            pptFlag = true;
@@ -447,26 +447,26 @@
         handout.setOriginHandoutId(handout.getHandoutId());
         this.saveHandout(handout);
         // 保存OrgText —— 讲义详情
         // 保存OrgText —— 讲义详情
         orgTextService.doSaveOrgText(handout.getHandoutId(), OrgText.TABLE_NAME_HANDOUT, handout.getRemark());
         // 更新上传文件使用轨迹
         // 更新上传文件使用轨迹
         fileUploadService.updateUploadTrace(fullPath, module, SysFileUploadTrace.FILE_USE, handout.getHandoutId());
         // 讲义和科目关联
         // 讲义和科目关联
         this.insertReCourse(collegeCourseId, handout.getHandoutId());
         // 删除pdf ppt原文件,已上传至阿里与服务器
         // 删除pdf ppt原文件,已上传至阿里与服务器
         // FileUtils.deleteQuietly(file);
         // insertAppointSelfOrg(handout.getHandoutId(),ClientUtils.getOrgId(),collegeCourseId);
         Result result = new Result(true);
         result.addData("pptFlag", pptFlag);
         return result;
      } catch (Exception e) {
         this.log.error("讲义转码失败" + fullPath, e);
         this.log.error("讲义转码失败" + fullPath, e);
      } finally {
         if (file != null) {
            // 删除下载到应用服务器的文档
            // 删除下载到应用服务器的文档
            fileUploadService.doDeleteTempOssFile(file.getParentFile(), module, ClientUtils.getUserId());
         }
      }
@@ -474,7 +474,7 @@
   }
   /**
    * 编辑讲义
    * 编辑讲义
    */
   public Result doEditHandout(SchHandout newhandout, String type) {
      SchHandout handout = read(SchHandout.class, newhandout.getHandoutId());
@@ -488,10 +488,10 @@
      TraceUtils.setUpdateTrace(handout);
      this.saveHandout(handout);
      // 保存OrgText —— 讲义详情
      // 保存OrgText —— 讲义详情
      orgTextService.doSaveOrgText(handout.getHandoutId(), OrgText.TABLE_NAME_HANDOUT, newhandout.getRemark());
      // 更新统计表讲义名字
      // 更新统计表讲义名字
      updateHandoutStatisticName(handout.getHandoutId(), handout.getName());
      /*
@@ -525,7 +525,7 @@
       * schHandout.setSubjectId(scs.getClassSubjectId());
       * schHandout.setSubjectName(scs.getName()); this.saveHandout(schHandout); }
       * 
       * // 保存OrgText —— 讲义详情 orgTextService.doSaveOrgTexts(handoutIds,
       * // 保存OrgText —— 讲义详情 orgTextService.doSaveOrgTexts(handoutIds,
       * OrgText.TABLE_NAME_HANDOUT, newhandout.getRemark());
       */
@@ -533,7 +533,7 @@
   }
   /**
    * 更新统计表讲义名字
    * 更新统计表讲义名字
    * 
    * @param handoutId
    * @param handoutName
@@ -550,7 +550,7 @@
   }
   /**
    * 得到office 文档是否有密码
    * 得到office 文档是否有密码
    * 
    * @param file
    * @param fileType
@@ -568,7 +568,7 @@
   }
   /**
    * ppt 检测是否包含密码
    * ppt 检测是否包含密码
    * 
    * @param file
    * @return
@@ -586,14 +586,14 @@
         HSLFSlideShow hss = new HSLFSlideShow(fs);
         IOUtils.closeQuietly(fs);
      } catch (IOException e) {
         log.error("PPT: getPPTDecryptFlag IOException :" + e);
         log.error("PPT: getPPTDecryptFlag IOException :" + e);
      } catch (EncryptedPowerPointFileException e) {
         if ("The CurrentUserAtom specifies that the document is encrypted".equals(e.getMessage())
               || "Encrypted PowerPoint files are not supported".equals(e.getMessage())) {
            flag = true;
         }
      } catch (Exception e) {
         log.error("PPT: getPPTDecryptFlag Exception :" + e);
         log.error("PPT: getPPTDecryptFlag Exception :" + e);
      }
      return flag;
@@ -601,7 +601,7 @@
   }
   /**
    * pptx 检测是否有密码,07+ 无打开文件密码,有编辑密码,暂时判断不出来
    * pptx 检测是否有密码,07+ 无打开文件密码,有编辑密码,暂时判断不出来
    * 
    * @param file
    * @return
@@ -623,31 +623,31 @@
            }
         }
      } catch (FileNotFoundException e) {
         log.error("getPPTXDecryptFlag()_获取InputStream 异常:" + e);
         log.error("getPPTXDecryptFlag()_获取InputStream 异常:" + e);
      } catch (IOException e) {
         log.error("getPPTXDecryptFlag()_获取POIFSFileSystem 异常:" + e);
         log.error("getPPTXDecryptFlag()_获取POIFSFileSystem 异常:" + e);
      } catch (NullPointerException e) {
         log.error("getPPTXDecryptFlag()_获取EncryptionInfo,07+ 异常:" + e);
         log.error("getPPTXDecryptFlag()_获取EncryptionInfo,07+ 异常:" + e);
      } catch (GeneralSecurityException e) {
         log.error("getPPTXDecryptFlag()_获取verifyPassword 异常:" + e);
         log.error("getPPTXDecryptFlag()_获取verifyPassword 异常:" + e);
      } catch (Exception e) {
         log.error("PPTX: getPPTXDecryptFlag Exception :" + e);
         log.error("PPTX: getPPTXDecryptFlag Exception :" + e);
      }
      return flag;
   }
   /**
    * 使用jacob另存为图片,需要测试多个请求同时调用情况 1.office2013报错,但是用office2013另存為效果最好
    * 2.office2007解析不完美,字体偏粗,边上有较明显锯齿,可以用jacob調用
    * 3.office2010解析基本正常,但是较于office2013,大字体和边框会有非常少量锯齿(推荐使用)
    * 使用jacob另存为图片,需要测试多个请求同时调用情况 1.office2013报错,但是用office2013另存為效果最好
    * 2.office2007解析不完美,字体偏粗,边上有较明显锯齿,可以用jacob調用
    * 3.office2010解析基本正常,但是较于office2013,大字体和边框会有非常少量锯齿(推荐使用)
    * 
    * info:服务器推荐使用office2010,jacob.jar包更新后如果支持office2013,测试哪个版本会效果更好,可以替换服务器office版本
    * info:服务器推荐使用office2010,jacob.jar包更新后如果支持office2013,测试哪个版本会效果更好,可以替换服务器office版本
    * 
    * @param file
    *            ppt文件
    *            ppt文件
    * @param docPath
    *            oss 存放office文件的路径
    *            oss 存放office文件的路径
    * @return
    */
   @Override
@@ -659,38 +659,38 @@
      try {
         if (!file.exists()) {
            throw new Exception("文件不存在!");
            throw new Exception("文件不存在!");
         }
         // 获取另存为图片时的文件
         // 获取另存为图片时的文件
         File imgFile = getHandoutImgPath(file.getParentFile().getPath());
         log.debug("消息调用JACOB解析ppt成功,进入解析方法,开始初始化JACOB组件!");
         log.debug("消息调用JACOB解析ppt成功,进入解析方法,开始初始化JACOB组件!");
         ComThread.InitSTA();
         log.debug("开始初始化JACOB组件,ComThread.InitSTA()调用成功!");
         log.debug("开始初始化JACOB组件,ComThread.InitSTA()调用成功!");
         application = new ActiveXComponent("PowerPoint.Application");
         // 默认不可见,但是大文件另存为时,会出现“ESC可取消保存”的进度框,暂时不知道如何不显示进度条
         // 默认不可见,但是大文件另存为时,会出现“ESC可取消保存”的进度框,暂时不知道如何不显示进度条
         // Dispatch.put(application, "Visible", new Variant(true));
         // 打开一个现有的 Presentation 对象
         // 打开一个现有的 Presentation 对象
         Dispatch ppts = application.getProperty("Presentations").toDispatch();
         ppt = Dispatch.call(ppts, "Open", file.getPath(), true, // ReadOnly
               false, // Untitled指定文件是否有标题
               false// WithWindow指定文件是否可见
               false, // Untitled指定文件是否有标题
               false// WithWindow指定文件是否可见
         ).toDispatch();
         // 另存为图片 (17):图片类型
         // 将web服务器中的ppt另存为图片,调用ppt的另存为方法,图片格式为(幻灯片1.JPG,幻灯片2.JPG...)
         // 另存为图片 (17):图片类型
         // 将web服务器中的ppt另存为图片,调用ppt的另存为方法,图片格式为(幻灯片1.JPG,幻灯片2.JPG...)
         Dispatch.call(ppt, "SaveAs", imgFile.getPath(), new Variant(17));
         // 上传图片到oss服务器并准备需要保存到数据库的handoutpage数据
         // 上传图片到oss服务器并准备需要保存到数据库的handoutpage数据
         results = uploadImgPrepareData(imgFile, docPath, handoutId);
      } catch (ComFailException e) {
         log.error("ComFailException解析保存ppt异常:" + e, e);
         log.error("ComFailException解析保存ppt异常:" + e, e);
      } catch (Exception e) {
         log.error("Exception解析保存ppt异常:" + e, e);
         log.error("Exception解析保存ppt异常:" + e, e);
      } finally {
         if (ppt != null) {
            Dispatch.call(ppt, "Close");
@@ -705,10 +705,10 @@
   }
   /**
    * 创建另存为图片文件路径,ppt解析的图片存在ppt同级目录image文件夹下,默认命名方式为:幻灯片1.JPG
    * 创建另存为图片文件路径,ppt解析的图片存在ppt同级目录image文件夹下,默认命名方式为:幻灯片1.JPG
    * 
    * @param path
    *            ppt上传到web服务器的路径
    *            ppt上传到web服务器的路径
    * @return
    */
   private File getHandoutImgPath(String path) {
@@ -718,7 +718,7 @@
   }
   /**
    * 将解析后的图片上传到oss,并且返回需要存储到数据库的handoutpage信息
    * 将解析后的图片上传到oss,并且返回需要存储到数据库的handoutpage信息
    * @param imgFileDir
    * @param docPath
    * @param handoutId
@@ -734,7 +734,7 @@
            String[] filelist = imgFileDir.list();
            // 判断是否有另存为的图片
            // 判断是否有另存为的图片
            if (null != filelist && filelist.length > 0) {
               results = new ArrayList<SchHandoutPage>(filelist.length);
               File imgFile;
@@ -748,12 +748,12 @@
               for (String strFile : filelist) {
                  // cacheService.set("handout_upload_schedule_"+handoutId, 60,
                  // i*100f/filelist.length);
                  // 直接使用strPath构造imgFile,会导致获取输入流时,报错,file只给文件名,默认为工程目录,和src同级,用全路径构造
                  // 直接使用strPath构造imgFile,会导致获取输入流时,报错,file只给文件名,默认为工程目录,和src同级,用全路径构造
                  imgFile = new File(imgFileDir.getPath() + "/" + strFile);
                  if (imgFile.getName().indexOf(".") != -1) {
                     // 图片文件名
                     // 图片文件名
                     String imgFileName = imgFile.getName().split("\\.")[0];
                     // 图片文件类型
                     // 图片文件类型
                     String imgFileType = imgFile.getName().split("\\.")[1];
                     if (StringUtils.isNotBlank(imgFileName) && imgFileName.length() > 3) {
@@ -772,11 +772,11 @@
               }
            } else {
               log.error("jacob解析失败,无另存为的图片,image文件夹为空:" + imgFileDir.getPath());
               log.error("jacob解析失败,无另存为的图片,image文件夹为空:" + imgFileDir.getPath());
               return Collections.EMPTY_LIST;
            }
         } else {
            log.error("jacob解析失败,未生成imgFileDir文件夹");
            log.error("jacob解析失败,未生成imgFileDir文件夹");
            return Collections.EMPTY_LIST;
         }
      } finally {
@@ -786,7 +786,7 @@
   }
   /**
    * 使用jpedal转换pdf为图片,默认格式为1.PNG、2.PNG、3.PNG
    * 使用jpedal转换pdf为图片,默认格式为1.PNG、2.PNG、3.PNG
    * 
    * @param
    *
@@ -796,7 +796,7 @@
   private List<SchHandoutPage> convertPDFToPNG(File file, String module, String handoutId) {
//      List<SchHandoutPage> results = new ArrayList<SchHandoutPage>(30);
//      // 得到转换对象
//      // 得到转换对象
//      ConvertPagesToImages objConvert = new ConvertPagesToImages(file.getPath());
//      try {
//         if (objConvert.openPDFFile()) {
@@ -806,10 +806,10 @@
//            for (int iPage = 1; iPage <= pageCount; iPage++) {
//               // cacheService.set("handout_upload_schedule_"+handoutId, 60,
//               // iPage*100f/pageCount);
//               // 得到解析的每一页图片
//               // 得到解析的每一页图片
//               BufferedImage img = objConvert.getPageAsImage(iPage, true);
//
//               // 判断图片是否高大于宽
//               // 判断图片是否高大于宽
//               int width = img.getWidth();
//               int height = img.getHeight();
//               BufferedImage handlerImg = null;
@@ -817,7 +817,7 @@
//                  handlerImg = rotatePdfImg(img, 270, null);
//               }
//
//               // 上传
//               // 上传
//               String destPath = "/web/res/img/school/handout/" + file.getParentFile().getName() + "/" + iPage
//                     + ".PNG";
//               String directory = webPath + "res/img/school/handout/" + file.getParentFile().getName();
@@ -836,13 +836,13 @@
//         }
//         objConvert.closePDFfile();
//      } catch (PdfException e) {
//         log.error("jpedal解析pdf为图片失败:", e);
//         log.error("jpedal解析pdf为图片失败:", e);
//         return Collections.EMPTY_LIST;
//      } catch (IOException e) {
//         log.error("pdf解析为图片失败:", e);
//         log.error("pdf解析为图片失败:", e);
//         return Collections.EMPTY_LIST;
//      } finally {
//         // 删除下载到应用服务器的文档
//         // 删除下载到应用服务器的文档
//         fileUploadService.doDeleteTempOssFile(file.getParentFile(), module, ClientUtils.getUserId());
//      }
@@ -851,11 +851,11 @@
   private BufferedImage rotatePdfImg(BufferedImage image, int degree, Color bgcolor) {
      int degree0 = degree;
      // 原始图象的宽高
      // 原始图象的宽高
      int iwidth = image.getWidth();
      int iheight = image.getHeight();
      // 处理的宽高
      // 处理的宽高
      int width = 0;
      int height = 0;
      int positionX = 0;
@@ -865,10 +865,10 @@
         degree0 = 360 + degree0;
      }
      // 将角度转为弧度
      // 将角度转为弧度
      double ang = Math.toRadians(degree0);
      // 确定旋转后的图象的高度和宽度
      // 确定旋转后的图象的高度和宽度
      if (degree0 == 180 || degree0 == 0 || degree0 == 360) {
         width = iwidth;
         height = iheight;
@@ -882,7 +882,7 @@
         height = (int) (sinVal * iwidth) + (int) (cosVal * iheight);
      }
      // 确定原点坐标
      // 确定原点坐标
      positionX = (width - iwidth) / 2;
      positionY = (height - iheight) / 2;
      BufferedImage rotatedImage = new BufferedImage(width, height, image.getType());
@@ -895,7 +895,7 @@
      }
      AffineTransform at = new AffineTransform();
      // 旋转图象
      // 旋转图象
      at.rotate(ang, width / 2, height / 2);
      at.translate(positionX, positionY);
      AffineTransformOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
@@ -906,7 +906,7 @@
   }
   /**
    * 新增HandoutPage对象
    * 新增HandoutPage对象
    * @param path
    * @param i
    * @return
@@ -921,7 +921,7 @@
      page.setImgPath(path0);
      // 旧版本convertPPTToPNG 这里为(i + 1) convertPPTToJPG 为i
      // 旧版本convertPPTToPNG 这里为(i + 1) convertPPTToJPG 为i
      page.setPageOrder(i);
      TraceUtils.setCreateTrace(page);
      return page;
@@ -936,7 +936,7 @@
   @Override
   public Result deleteHandouts(String[] handoutIds) {
      if (handoutIds.length == 0) {
         return new Result(false, "参数错误");
         return new Result(false, "参数错误");
      }
      for (String handoutId : handoutIds) {
         SchHandout interact = read(SchHandout.class, handoutId);
@@ -954,10 +954,10 @@
      for (String handoutId : handoutIds) {
         if ((orgIds != null && orgIds.length != 0) || (classIds != null && classIds.length != 0)) {
            // 删除需要回撤的讲义
            // 删除需要回撤的讲义
            deleteAppoint(handoutId, orgIds, classIds);
         } else {
            // 删除讲义
            // 删除讲义
            String hql = " from SchHandoutReCourse where handoutId = ? and deleteFlag is false and orgId = ?";
            SchHandoutReCourse shr = findUnique(hql, CollectionUtils.newList(handoutId, ClientUtils.getOrgId()),
                  SchHandoutReCourse.class);
@@ -973,7 +973,7 @@
             * null){ TraceUtils.setUpdateTrace(handout); handout.setDeleteFlag(true);
             * this.saveHandout(handout); }
             */
            // 用户选择同时删除下级讲义
            // 用户选择同时删除下级讲义
            if (delAll == 1) {
               deleteSub(handoutId, ClientUtils.getOrgId());
            }
@@ -986,7 +986,7 @@
   @SuppressWarnings("unchecked")
   private void deleteSub(String handoutId, 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 ";
@@ -1004,7 +1004,7 @@
         save(schHandoutReCourse);
      }
      // 班主任层面视频指定过后都是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());
@@ -1025,7 +1025,7 @@
   private Result deleteAppoint(String handoutId, String orgIds[], String classIds[]) {
      Map<String, Object> args = new HashMap<String, Object>();
      // 删除需要回撤的机构讲义
      // 删除需要回撤的机构讲义
      if (orgIds.length != 0) {
         String hql = " from SchHandoutReCourse where handoutId = :handoutId and deleteFlag is false and orgId in (:orgIds) and orgId != :currOrgId";
@@ -1043,7 +1043,7 @@
         }
      }
      // 删除需要回撤的班主任讲义
      // 删除需要回撤的班主任讲义
      if (classIds.length != 0) {
         args = new HashMap<String, Object>();
         args.put(HANDOUT_ID, handoutId);
@@ -1062,7 +1062,7 @@
   }
   /**
    * 获取讲义列表数据
    * 获取讲义列表数据
    * 
    * @return
    */
@@ -1075,8 +1075,8 @@
      String hql = "";
      List<Object> agrs = new ArrayList<Object>();
      agrs.add(ClientUtils.getClassId());
      // 1班主任:获取该班级(class_id)下面的讲师负责课程下的讲义;
      // 2讲师:获取该讲师(teacher_id)负责课程下的讲义
      // 1班主任:获取该班级(class_id)下面的讲师负责课程下的讲义;
      // 2讲师:获取该讲师(teacher_id)负责课程下的讲义
      if (user != null && UserInfoWrapper.ROLE_CHARGER.equals(ClientUtils.getCurrentRole())) {
         hql = "select h.handoutId,h.name,h.pageCount,h.status,h.subjectId,h.subjectName, h.orderNum, h.remark  "
               + " from SchHandout h " + " where h.deleteFlag is false " + " and h.classId = ?";
@@ -1085,7 +1085,7 @@
               + " from SchHandout h " + " where h.deleteFlag is false " + " and h.classId = ?";
      }
      if (StringUtils.isNotBlank(tid)) {
         // 其他
         // 其他
         if ("-1".equals(tid)) {
            hql = hql.concat(
                  " and not EXISTS (select 1 from SchClassSubject t where t.deleteFlag is false and t.classSubjectId = h.subjectId) ");
@@ -1116,7 +1116,7 @@
   }
   /**
    * 获取机构讲义列表数据
    * 获取机构讲义列表数据
    * 
    * @return
    */
@@ -1126,7 +1126,7 @@
      List<Object[]> handoutLst = null;
      List<Object> args = new ArrayList<Object>();
      String hql = "";
      // 其他
      // 其他
      if (("-" + collegeCourseId).equals(subjectId)) {
         hql = "select v.handoutId,v.name,v.pageCount,v.status,'','','',0,v.subjectId from SchHandout v,SchHandoutReCourse r where v.collegeCourseId = ? and v.deleteFlag is false and r.deleteFlag is false and r.handoutId = v.handoutId and r.orgId = ? and"
               + " not EXISTS (select 1 from SchSubject t where t.deleteFlag is false and t.subjectId = v.subjectId)";
@@ -1171,7 +1171,7 @@
   }
   /**
    * 指定机构讲义
    * 指定机构讲义
    * 
    * @return
    */
@@ -1180,9 +1180,9 @@
         String collegeCourseId) {
      if (null == handoutIds || handoutIds.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) {
@@ -1191,14 +1191,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 SchHandoutReCourse where handoutId in (:handoutIds) and deleteFlag is false and orgId = :currOrgId";
      argsMap = new HashMap<String, Object>();
@@ -1210,10 +1210,10 @@
      }
      for (String handoutId : handoutIds) {
         if (orgIds.length > 0) { // 指定给机构
         if (orgIds.length > 0) { // 指定给机构
            insertAppointOrg(orgIds, handoutId, collegeCourseId, orderMap);
         }
         if (classIds.length > 0) { // 指定给班级
         if (classIds.length > 0) { // 指定给班级
            insertAppointClass(classIds, handoutId, classMap, collegeCourseId, orderMap);
         }
      }
@@ -1222,7 +1222,7 @@
   }
   /**
    * 指定给机构
    * 指定给机构
    * 
    * @param orgIds
    * @param handoutId
@@ -1239,7 +1239,7 @@
      for (String orgId : orgIds) {
         orgList.add(orgId);
      }
      // 剔除掉不符合条件的orgId
      // 剔除掉不符合条件的orgId
      orgList.removeAll(strings);
      if (orgList.isEmpty()) {
         return;
@@ -1259,7 +1259,7 @@
   }
   /**
    * 指定给班级
    * 指定给班级
    * 
    * @param classIds
    * @param handoutId
@@ -1268,7 +1268,7 @@
   private void insertAppointClass(String classIds[], String handoutId, Map<String, String> classMap,
         String collegeCourseId, Map<String, Integer> orderMap) {
      // 章节id
      // 章节id
      Map<String, SubjectChapter> origChapterMap = new HashMap<String, SubjectChapter>();
      SchHandout handout = read(SchHandout.class, handoutId);
@@ -1285,7 +1285,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());
@@ -1327,7 +1327,7 @@
         this.saveHandout(sh);
         // 插入OrgText
         // 插入OrgText
         orgTextService.doInsertOrgText(sh.getHandoutId(), OrgText.TABLE_NAME_HANDOUT,
               oldOrgText == null ? sh.getRemark() : oldOrgText.getContent());
@@ -1343,7 +1343,7 @@
            save(page);
         }
         // 标记班级有讲义
         // 标记班级有讲义
         ClsClass cls = read(ClsClass.class, classId);
         if (cls != null && cls.getHaveHandout() == ClsClass.NOT_HAVE_HANDOUT) {
            cls.setHaveHandout(ClsClass.HAVE_HANDOUT);
@@ -1364,11 +1364,11 @@
   @Override
   public Result doStartHandouts(String handoutIds) {
      if (StringUtils.isEmpty(handoutIds)) {
         return new Result(false, "参数错误");
         return new Result(false, "参数错误");
      }
      String[] handoutIdArray = handoutIds.split(",");
      // 发送讲义系统通知
      // 发送讲义系统通知
      sendSysMsg(handoutIds);
      for (String handoutId : handoutIdArray) {
@@ -1378,7 +1378,7 @@
         TraceUtils.setUpdateTrace(handout);
         this.saveHandout(handout);
         // 推送消息给学员
         // 推送消息给学员
         Map<String, String> extras = new HashMap<String, String>(1);
         extras.put("senderId", "sys_msg");
         extras.put("type", "SYS_MSG");
@@ -1391,8 +1391,8 @@
         for (List<String> userIds : lstUserIdList) {
            // jpushService.doJpushByUserIds(userIds, extras, "有新讲义", "发布了讲义:" +
            // handout.getName(), "发布了讲义:" + handout.getName());
            // jpushService.doJpushByUserIds(userIds, extras, "有新讲义", "发布了讲义:" +
            // handout.getName(), "发布了讲义:" + handout.getName());
         }
@@ -1402,7 +1402,7 @@
   }
   /**
    * 拆分成200人一组
    * 拆分成200人一组
    * @param classId
    * @return
    */
@@ -1414,13 +1414,13 @@
      // List<String> lstUserIds = userService.getUserLstByClassId(classId);
      List<String> lstUserIds = null;
      // 小于200 直接返回
      // 小于200 直接返回
      if (lstUserIds.size() < 200) {
         result.add(lstUserIds);
         return result;
      }
      // 大于200,分批处理
      // 大于200,分批处理
      int iSize = lstUserIds.size() / 200;
      int iLeft = lstUserIds.size() % 200;
      iSize = iLeft == 0 ? iSize : iSize + 1;
@@ -1431,11 +1431,11 @@
         lstSplitUserIds = new ArrayList<String>(200);
         // 200 个
         // 200 个
         if (i < (iSize - 1)) {
            lstSplitUserIds.addAll(lstUserIds.subList(i * 200, (i + 1) * 200));
         } else {
            // 最后剩下的,可能小于200个
            // 最后剩下的,可能小于200个
            lstSplitUserIds.addAll(lstUserIds.subList(i * 200, lstUserIds.size()));
         }
@@ -1448,7 +1448,7 @@
   }
   /**
    * 发送讲义系统消息
    * 发送讲义系统消息
    * @param handoutIds
    * @return
    */
@@ -1463,7 +1463,7 @@
      // msg.put("handoutIds", handoutIds);
      // try {
      // onsProducer.sendMsg(msg); //
      // 消费类:com.qxueyou.scc.school.service.impl.HandoutSysMsgDealService
      // 消费类:com.qxueyou.scc.school.service.impl.HandoutSysMsgDealService
      //
      // } catch (Exception e) {
      // log.error("call DocdealMsgSendService fail.userId: " +
@@ -1484,7 +1484,7 @@
   @Override
   public Result doStopHandouts(String[] handoutIds) {
      if (handoutIds.length == 0) {
         return new Result(false, "参数错误");
         return new Result(false, "参数错误");
      }
      for (String handoutId : handoutIds) {
         SchHandout interact = read(SchHandout.class, handoutId);
@@ -1497,7 +1497,7 @@
   }
   /**
    * 插入历史讲义
    * 插入历史讲义
    * 
    * @param handout
    * @param oldHandoutId
@@ -1540,7 +1540,7 @@
   }
   /**
    * 拷贝讲义
    * 拷贝讲义
    * @param oldHandoutId
    * @param subjectId
    * @param collegeCourseId
@@ -1585,7 +1585,7 @@
         saveOrUpdateAll(newHandoutPages);
      }
      // 非班级拷贝需要关联表新增记录
      // 非班级拷贝需要关联表新增记录
      if (StringUtils.isEmpty(ClientUtils.getClassId())) {
         this.insertReCourse(collegeCourseId, newHandout.getHandoutId());
      }
@@ -1594,13 +1594,13 @@
   }
   /**
    * 插入讲义和科目关联
    * 插入讲义和科目关联
    * 
    * @param collegeCourseId
    * @param handoutId
    */
   private void insertReCourse(String collegeCourseId, String handoutId) {
      // 序号
      // 序号
      String hql = "select MAX(c.orderNum) from SchHandoutReCourse c where c.deleteFlag is false and c.collegeCourseId = ? and orgId = ? ";
      Integer iMax = this.findUnique(hql, CollectionUtils.newList(collegeCourseId, ClientUtils.getOrgId()),
            Integer.class);
@@ -1622,7 +1622,7 @@
   }
   /**
    * 查询讲义列表
    * 查询讲义列表
    * 
    * @param hql
    * @param args
@@ -1634,21 +1634,21 @@
   }
   /**
    * 批量操作讲义收藏记录
    * 批量操作讲义收藏记录
    * 
    * @param lstFavor
    * @return
    */
   @Override
   public Result doOperHandoutFavorDataBatch(List<SchHandoutPageFavor> lstFavor) {
      // 批量增加或者更新
      // 批量增加或者更新
      this.saveOrUpdateAll(lstFavor);
      return new Result(true);
   }
   /**
    * 后台获取列表数据
    * 后台获取列表数据
    * 
    * @param sql
    * @param args
@@ -1660,7 +1660,7 @@
   }
   /**
    * 查询选择班级下历史讲义
    * 查询选择班级下历史讲义
    * @param sql
    * @param args
    * @return
@@ -1676,12 +1676,12 @@
      List<SchHandout> handouts = this.find(hql, CollectionUtils.newList(handout.getHandoutId()), SchHandout.class);
      if (null == handouts || handouts.isEmpty()) {
         return new Result(true, "无关联讲义");
         return new Result(true, "无关联讲义");
      }
      List<SchHandoutPage> allPages = new ArrayList<SchHandoutPage>();
      // 循环处理
      // 循环处理
      for (SchHandout ho : handouts) {
         TraceUtils.setUpdateTrace(ho);
@@ -1693,7 +1693,7 @@
         this.saveHandout(ho);
      }
      // 明细
      // 明细
      this.saveOrUpdateAll(allPages);
      return new Result(true);
@@ -1701,7 +1701,7 @@
   }
   /**
    * 赋值所有讲义明细
    * 赋值所有讲义明细
    * 
    * @param lstPages
    * @param handoutId
@@ -1730,7 +1730,7 @@
   }
   /**
    * 旋转讲义图片
    * 旋转讲义图片
    * 
    * @param angle
    * @param handoutPageId
@@ -1742,7 +1742,7 @@
      SchHandoutPage page = this.read(SchHandoutPage.class, handoutPageId);
      if (null == page) {
         return new Result(false, "page为空");
         return new Result(false, "page为空");
      }
      String imgPath = page.getImgPath();
@@ -1753,7 +1753,7 @@
      }
      if (StringUtils.isBlank(imgPath)) {
         return new Result(false, "path解析出错");
         return new Result(false, "path解析出错");
      }
      imgPath = imgPath.concat("@").concat(angle).concat("r");
@@ -1764,10 +1764,10 @@
   }
   /**
    * 查询讲义,模糊课程名或者讲义名
    * 查询讲义,模糊课程名或者讲义名
    * 
    * @param keyWord
    *            查询关键字
    *            查询关键字
    * @return
    */
   @Override
@@ -1783,7 +1783,7 @@
   }
   /**
    * 更新讲义观看量
    * 更新讲义观看量
    */
   public Result updatePlayCount(String handoutId) {
      SchHandout sh = read(SchHandout.class, handoutId);
@@ -1854,7 +1854,7 @@
         save(shrd);
      }
      // 统计表增加数据
      // 统计表增加数据
      hql = " from SchHandoutStatistic where userId=? and classId=? and handoutId=?";
      SchHandoutStatistic shs = findUnique(hql,
            CollectionUtils.newList(ClientUtils.getUserId(), ClientUtils.getClassId(), sh.getHandoutId()),
@@ -1878,11 +1878,11 @@
               CollectionUtils.newList(ClientUtils.getUserId(), ClientUtils.getClassId(), record.getHandoutId()));
         Set<String> set = new HashSet<String>();
         // 本次观看
         // 本次观看
         for (String string2 : nums) {
            set.add(string2);
         }
         // 数据库观看记录
         // 数据库观看记录
         set.addAll(pageLst);
         shs.setCompDegree(new BigDecimal(set.size()).divide(new BigDecimal(record.getPageCount()), 2,
@@ -1901,7 +1901,7 @@
   }
   /**
    * 讲义上传重复数据处理
    * 讲义上传重复数据处理
    * 
    * @param handoutId
    * @return
@@ -1931,16 +1931,16 @@
   }
   /**
    * 排序
    * 排序
    * 
    * @param ids
    *            排序id
    *            排序id
    * @param index
    *            序号
    *            序号
    * @return
    */
   public Result doOrder(List<String> ids, List<Integer> index) {
      // 循环修改order
      // 循环修改order
      CommonDAO commonDAO = this.getCommonDAO();
      for (int i = 0; i < ids.size(); i++) {
         String handoutId = ids.get(i);
@@ -1960,7 +1960,7 @@
   }
   /**
    * 保存讲义接口
    * 保存讲义接口
    * 
    * @param handout
    * @return