|  |  | 
 |  |  | import com.ruoyi.common.utils.file.FileUploadUtils; | 
 |  |  | import com.ruoyi.common.utils.file.FileUtils; | 
 |  |  | import com.ruoyi.framework.config.ServerConfig; | 
 |  |  | import com.ruoyi.system.domain.SysConfig; | 
 |  |  | import com.ruoyi.system.mapper.SysConfigMapper; | 
 |  |  | import com.smartor.domain.HtmlContentVO; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ServerConfig serverConfig; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private SysConfigMapper sysConfigMapper; | 
 |  |  |  | 
 |  |  |     private static final String FILE_DELIMETER = ","; | 
 |  |  |  | 
 |  |  | 
 |  |  |             convertDocToHtml(filePath + "\\" + file.getOriginalFilename(), filePath + "\\" + file.getOriginalFilename().split("\\.", 2)[0] + ".html"); | 
 |  |  |  | 
 |  |  |             String url = null; | 
 |  |  |             String xhPath = "http://218.108.11.22:8093/profile-api"; | 
 |  |  |             SysConfig config = new SysConfig(); | 
 |  |  |             config.setConfigKey("sys.qdip"); | 
 |  |  |             SysConfig sysConfig = sysConfigMapper.selectConfig(config); | 
 |  |  |             String xhPath = sysConfig.getConfigValue() + "/profile-api"; | 
 |  |  |             if (uploadSwitch == 1) { | 
 |  |  |                 String fn = fileName.replaceAll("\\.[^.]*$", ".html").replaceAll("/profile", ""); | 
 |  |  |                 url = xhPath + fn; | 
 |  |  | 
 |  |  |     @ApiOperation("富文本转html") | 
 |  |  |     @PostMapping("/htmlContent") | 
 |  |  |     public AjaxResult htmlContent(@RequestBody HtmlContentVO htmlContentVO) { | 
 |  |  |         log.error("htmlContentVO入参为:{}", htmlContentVO); | 
 |  |  |         log.info("htmlContentVO入参为:{}", htmlContentVO); | 
 |  |  |         // 获取文件的原始名称 | 
 |  |  |         String fileName = htmlContentVO.getFileName(); | 
 |  |  |         if (!fileName.endsWith(".html")) { | 
 |  |  | 
 |  |  |         // 将文件保存到指定目录 | 
 |  |  |         File outputFile = new File(RuoYiConfig.getUploadPath() + "/show/" + fileName.split("\\.", 2)[0] + "/" + fileName); | 
 |  |  |         try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"))) { | 
 |  |  |             if (StringUtils.isNotEmpty(htmlContentVO.getContent())) | 
 |  |  |                 writer.write(htmlContentVO.getContent()); | 
 |  |  |             if (StringUtils.isNotEmpty(htmlContentVO.getContent())) writer.write(htmlContentVO.getContent()); | 
 |  |  |         } catch (IOException e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取文件扩展名 | 
 |  |  |      */ | 
 |  |  |     private static String getFileExtension(String fileName) { | 
 |  |  |         int lastDotIndex = fileName.lastIndexOf('.'); | 
 |  |  |         if (lastDotIndex > 0) { | 
 |  |  |             return fileName.substring(lastDotIndex); | 
 |  |  |         } | 
 |  |  |         return ""; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 检查文件是否为支持的Word格式 | 
 |  |  |      */ | 
 |  |  |     public static boolean isSupportedWordFormat(String filePath) { | 
 |  |  |         if (filePath == null) return false; | 
 |  |  |         String fileName = filePath.toLowerCase(); | 
 |  |  |         return fileName.endsWith(".doc") || fileName.endsWith(".docx"); | 
 |  |  |     } | 
 |  |  | } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  |