zouyu
2025-11-20 be90adff42bb02c96252991c205b3a43bde9636d
src/main/java/com/chinaztt/mes/docx/util/TakeWords.java
@@ -2,7 +2,6 @@
import cn.hutool.core.io.FileUtil;
import com.chinaztt.mes.docx.dto.GetFileDto;
import com.chinaztt.mes.docx.dto.ThicknessData;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import com.opencsv.exceptions.CsvValidationException;
@@ -61,21 +60,25 @@
    public static Object readExcelFile(File file) throws IOException {
        StringBuilder result = new StringBuilder();
        //创建工作簿对象
        XSSFWorkbook xssfWorkbook = new XSSFWorkbook(Files.newInputStream(file.toPath()));
        //获取工作簿下sheet的个数 只读取第一个sheet
        try {
            XSSFWorkbook xssfWorkbook = new XSSFWorkbook(Files.newInputStream(file.toPath()));
            //获取工作簿下sheet的个数 只读取第一个sheet
//            int sheetNum = xssfWorkbook.getNumberOfSheets();
        //遍历工作簿中的所有数据
        XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
        //获取最后一行的num,即总行数。此处从0开始
        int maxRow = sheet.getLastRowNum();
        for (int row = 1; row <= maxRow; row++) {
            //获取最后单元格num,即总单元格数 ***注意:此处从1开始计数***
            int maxRol = sheet.getRow(row).getLastCellNum();
            StringBuilder aLine = new StringBuilder();
            for (int rol = 0; rol < maxRol; rol++) {
                aLine.append(sheet.getRow(row).getCell(rol)).append(splitIdentifier);
            //遍历工作簿中的所有数据
            XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
            //获取最后一行的num,即总行数。此处从0开始
            int maxRow = sheet.getLastRowNum();
            for (int row = 1; row <= maxRow; row++) {
                //获取最后单元格num,即总单元格数 ***注意:此处从1开始计数***
                int maxRol = sheet.getRow(row).getLastCellNum();
                StringBuilder aLine = new StringBuilder();
                for (int rol = 0; rol < maxRol; rol++) {
                    aLine.append(sheet.getRow(row).getCell(rol)).append(splitIdentifier);
                }
                result.append(aLine).append("\n");
            }
            result.append(aLine).append("\n");
        }catch (Exception e){
            e.printStackTrace();
        }
        return result.toString();
    }
@@ -232,6 +235,7 @@
        StringBuilder stringBuilder = new StringBuilder();
        String strTmp = "";
        while ((strTmp = buffReader.readLine()) != null) {
            strTmp = strTmp.replaceAll("\t",",");
            stringBuilder.append(strTmp).append("\n");
        }
        buffReader.close();
@@ -365,12 +369,20 @@
            // 构建基础 SQL
            String sql = "SELECT * FROM "+table+" WHERE 1=1";
            if(StringUtils.isNotBlank(getFileDto.getMdbEntrustCode())){
                sql+=" AND " + getFileDto.getMdbEntrustCode() + " = '" + getFileDto.getEntrustCode()+ "'";
            if(StringUtils.isNotBlank(getFileDto.getMdbEntrustCode()) ){
                sql+=" AND (" + getFileDto.getMdbEntrustCode() + " = '" + getFileDto.getEntrustCode()+ "'";
                if(StringUtils.isNotBlank(getFileDto.getLotBatchNo())){
                    sql+=" OR "+ getFileDto.getMdbEntrustCode() + " = '" + getFileDto.getLotBatchNo()+ "'";
                }
                sql+=")";
            }
            if(StringUtils.isNotBlank(getFileDto.getMdbSampleCode())){
                sql+=" AND " + getFileDto.getMdbSampleCode() + " = '" + getFileDto.getSampleCode() + "'";
            }
            if(StringUtils.isNotBlank(getFileDto.getCableTag())){
                sql+=" AND Color = '" + getFileDto.getCableTag() + "'";
            }
            // 创建 PreparedStatement 对象执行 SQL
            preparedStatement = connection.prepareStatement(sql);
            resultSet = preparedStatement.executeQuery();