| | |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.file.config.CmnConst; |
| | | import com.product.file.config.FileCode; |
| | | import com.product.file.util.AsposeUtil; |
| | | import com.product.file.util.CreateDocumentIndexThread; |
| | | import com.product.file.util.FileUtil; |
| | | import com.product.file.util.FileUtils; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 移动端升级,安装包下载 |
| | | * |
| | | * @param fse |
| | | * @param response |
| | | */ |
| | | public void getFileContent(FieldSetEntity fse, HttpServletResponse response,boolean isUpgrade) throws IOException { |
| | | if(isUpgrade) { |
| | | public void getFileContent(FieldSetEntity fse, HttpServletResponse response, boolean isUpgrade) throws IOException { |
| | | if (isUpgrade) { |
| | | FieldSetEntity attachmentFse = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_ATTACHMENTS, fse.getUUID(), false); |
| | | if (attachmentFse == null || !"product_sys_app_version".equals(attachmentFse.getString("attachment_data_table")) ) { |
| | | if (attachmentFse == null || !"product_sys_app_version".equals(attachmentFse.getString("attachment_data_table"))) { |
| | | return; |
| | | } |
| | | logger.info("正在获取文件流..."); |
| | |
| | | String viewOnlineSign = attachmentFse.getString(CmnConst.VIEW_ONLINE_SIGN); |
| | | boolean encrptSignFlag = "1".equals(attachmentFse.getString(CmnConst.ENCRPT_SIGN)); |
| | | boolean needOnlineViewFlag = "1".equals(fse.getString(CmnConst.NEED_ONLINE_VIEW)) && "1".equals(viewOnlineSign); |
| | | |
| | | String clientType =CoreConst.CLIENT_TYPE_APP; |
| | | |
| | | String clientType = CoreConst.CLIENT_TYPE_APP; |
| | | |
| | | String contentType = "multipart/form-data"; |
| | | boolean isExcel = realFileName.endsWith(".xlsx") || realFileName.endsWith(".xls"); |
| | |
| | | } |
| | | logger.info("文件流获取成功"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 提取文件信息-下载文件或者在线预览文件 |
| | | * |
| | |
| | | tempOs.flush(); |
| | | tempOs.close(); |
| | | } |
| | | boolean delete = false; |
| | | if (realFileName.endsWith(".xls") && needOnlineViewFlag && localTempFile.exists() && !CoreConst.CLIENT_TYPE_APP.equals(clientType)) { |
| | | //转换为xlsx |
| | | AsposeUtil.xls2xlsx(localTempFile.getPath(), getSystemConfig("temp.dir", "/attachment/temp") + "/" + localTempFile.getName(), "xls"); |
| | | File oldFile = localTempFile; |
| | | localTempFile = new File(getSystemConfig("temp.dir", "/attachment/temp") + "/" + localTempFile.getName()); |
| | | if (!localTempFile.isFile()) { |
| | | localTempFile = oldFile; |
| | | } else { |
| | | delete = true; |
| | | oldFile.delete(); |
| | | } |
| | | } |
| | | response.setContentLengthLong(localTempFile.length()); |
| | | InputStream is = new FileInputStream(localTempFile); |
| | | int len; |
| | |
| | | FileUtils.convertPdf(false, false, encrptSignFlag, true, tempSourceFile, dir, fileName, attachmentFse.getString(CmnConst.FILE_NAME)); |
| | | tempSourceFile.delete(); |
| | | } |
| | | boolean delete = false; |
| | | if (realFileName.endsWith(".xls") && needOnlineViewFlag && file.exists() && !CoreConst.CLIENT_TYPE_APP.equals(clientType)) { |
| | | //转换为xlsx |
| | | AsposeUtil.xls2xlsx(file.getPath(), getSystemConfig("temp.dir", "/attachment/temp") + "/" + file.getName(), "xls"); |
| | | File oldFile = file; |
| | | file = new File(getSystemConfig("temp.dir", "/attachment/temp") + "/" + file.getName()); |
| | | if (!file.isFile()) { |
| | | file = oldFile; |
| | | } else { |
| | | delete = true; |
| | | } |
| | | } |
| | | int len; |
| | | byte[] b = new byte[1024]; |
| | | InputStream is = new FileInputStream(file); |
| | |
| | | os.flush(); |
| | | } |
| | | is.close(); |
| | | if (delete) { |
| | | file.delete(); |
| | | } |
| | | } |
| | | logger.info("文件流获取成功"); |
| | | } |