zouyu
2026-06-03 5058481100d938bc4680725c3659757a09a2dd8a
src/main/java/com/chinaztt/mes/docx/util/TakeWords.java
@@ -7,6 +7,7 @@
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import com.opencsv.exceptions.CsvValidationException;
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import org.apache.commons.lang3.ObjectUtils;
@@ -27,6 +28,7 @@
import java.util.*;
import java.util.regex.Pattern;
@Slf4j
public class TakeWords {
    private static final String splitIdentifier = "@-@"; // 自定义唯一标识符
@@ -35,6 +37,11 @@
    private static final Pattern SCIENTIFIC_PATTERN = Pattern.compile(
            "^[+-]?\\d+(\\.\\d+)?[eE][+-]?\\d+$"
    );
    /**
     * 处理mdb数据库排除字段类型
     */
    private final static List<String> MDB_EXCLUDE_TYPES = Arrays.asList("java.sql.Blob");
    public static Object readWordFile(File file) {
        String result = "";
@@ -243,11 +250,17 @@
            rs = preparedStatement.executeQuery();
            ResultSetMetaData data = rs.getMetaData();
            while (rs.next()) {
                Map<String, String> map = new HashMap<>();
                Map<String, Object> map = new HashMap<>();
                for (int i = 1; i <= data.getColumnCount(); i++) {
                    //列名
                    String columnName = data.getColumnName(i);
                    map.put(columnName, rs.getString(i));
                    //列字段类型
                    String columnClassName = data.getColumnClassName(i);
                    Object columnValue = null;
                    if(!MDB_EXCLUDE_TYPES.contains(columnClassName)){
                        columnValue = rs.getObject(i);
                    }
                    map.put(columnName, columnValue);
                }
                list.add(map);
            }
@@ -477,7 +490,7 @@
            return Result.failed("数据库名或表名不能为空");
        }
        // 数据库连接信息
        String url = "jdbc:sqlserver://localhost:1433;DatabaseName="+dbName+";encrypt=true;trustServerCertificate=true";
        String url = "jdbc:sqlserver://localhost:1433;DatabaseName="+dbName+";encrypt=false;trustServerCertificate=true";
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
@@ -489,17 +502,17 @@
            String sql = "SELECT * FROM "+table+" WHERE 1=1";
            if(StringUtils.isNotBlank(getFileDto.getMdbEntrustCode()) ){
                sql+=" AND (" + getFileDto.getMdbEntrustCode() + " = TRIM('" + getFileDto.getEntrustCode()+ "')";
                sql+=" AND (" + getFileDto.getMdbEntrustCode() + " = LTRIM(RTRIM('" + getFileDto.getEntrustCode()+ "'))";
                if(StringUtils.isNotBlank(getFileDto.getLotBatchNo())){
                    sql+=" OR "+ getFileDto.getMdbEntrustCode() + " = TRIM('" + getFileDto.getLotBatchNo()+ "')";
                    sql+=" OR "+ getFileDto.getMdbEntrustCode() + " = LTRIM(RTRIM('" + getFileDto.getLotBatchNo()+ "'))";
                }
                sql+=")";
            }
            if(StringUtils.isNotBlank(getFileDto.getMdbSampleCode())){
                sql+=" AND " + getFileDto.getMdbSampleCode() + " = '" + getFileDto.getSampleCode() + "'";
            }
            if(StringUtils.isNotBlank(getFileDto.getCableTag())){
                sql+=" AND Color = '" + getFileDto.getCableTag() + "'";
            if(StringUtils.isNotBlank(getFileDto.getLastSql())){
                sql+=getFileDto.getLastSql();
            }
            // 创建 PreparedStatement 对象执行 SQL
            preparedStatement = connection.prepareStatement(sql);
@@ -537,4 +550,5 @@
        }
        return tableMap;
    }
}