| | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.chinaztt.mes.docx.dto.GetFileDto; |
| | | import com.chinaztt.mes.docx.dto.ThicknessData; |
| | | import com.chinaztt.mes.docx.service.DocxService; |
| | | import com.chinaztt.mes.docx.util.R; |
| | | import com.chinaztt.mes.docx.util.TakeWords; |
| | | import net.sourceforge.tess4j.TesseractException; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.*; |
| | | import java.sql.*; |
| | | import java.io.File; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | @Override |
| | | public R<?> getFile(GetFileDto getFileDto) throws IOException, SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, TesseractException { |
| | | File file = getFileStart(getFileDto.getFilePath(), getFileDto.getFileExtension()); |
| | | if (file != null) { |
| | | if (file != null && !file.exists()) { |
| | | return R.failed("未查询到该路径:" + getFileDto.getFilePath() + "下存在:" + getFileDto.getFileExtension() + "结尾的文件!"); |
| | | } |
| | | switch (getFileDto.getFileExtension()) { |
| | |
| | | return R.ok(TakeWords.getMysqlFile(getFileDto)); |
| | | case ".png": |
| | | return R.ok(TakeWords.readPngFile(file)); |
| | | case ".mqtt": |
| | | return R.ok("mqtt---"); |
| | | default: |
| | | return R.failed("后缀名配置错误!"); |
| | | } |
| | |
| | | boolean b; |
| | | switch (fileExtension) { |
| | | case ".docx": |
| | | b = i.getName().endsWith(".docx") || i.getName().endsWith(".doc"); |
| | | b = i.getName().endsWith(".docx") || i.getName().endsWith(".doc") || i.getName().endsWith(".DOCX") || i.getName().endsWith(".DOC"); |
| | | break; |
| | | case ".xlsx": |
| | | b = i.getName().endsWith(".xlsx") || i.getName().endsWith(".xls"); |
| | | |
| | | b = i.getName().endsWith(".xlsx") || i.getName().endsWith(".xls") || i.getName().endsWith(".XLSX") || i.getName().endsWith(".XLS"); |
| | | break; |
| | | default: |
| | | b = i.getName().endsWith(fileExtension); |