zouyu
2026-04-15 7f75b111c64641a21b8f3784fb9b4cc34e681b2d
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -12,7 +12,6 @@
import com.alibaba.fastjson.JSONObject;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -2426,7 +2425,7 @@
        List<String> resultChList = new ArrayList<>();
        List<String> resultEnList = new ArrayList<>();
        // 判断是否是只有一个样品
        boolean isOneSample = samples.size() == 1 ? true : false;
        boolean isOneSample = samples.size() == 1;
        /*基础报告(根据绘制的原始记录模版形成)*/
        samples.forEach(a -> {
            models.add(a.getModel());
@@ -2544,26 +2543,27 @@
                    newTableRenderData.setRows(new ArrayList<>(firstTwoRows));
                    //设置样式
                    TableStyle tableStyle = new TableStyle();
                    for (int i = 1; i <= max; i++) {
                        // 根据减压那结果个数修改长度
                        switch (i) {
                            case 1:
                                tableStyle.setColWidths(new int[]{650, 2000, 2000, 850, 2200, 2100, 1200});
                                break;
                            case 2:
                                tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 2100, 1200, 1200, 1200});
                                break;
                            case 3:
                                tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 1500, 1000, 1000, 1000, 1200});
                                break;
                            case 4:
                                tableStyle.setColWidths(new int[]{650, 1200, 1200, 850, 1400, 850, 850, 850, 850, 1200});
                                break;
                            case 5:
                                tableStyle.setColWidths(new int[]{650, 1100, 1100, 850, 1350, 750, 750, 750, 750, 750, 1200});
                                break;
                        }
                    }
//                    for (int i = 1; i <= max; i++) {
//                    }
                    // 根据检验结果个数修改长度
                    tableStyle.setColWidths(calcTableColWidths(max));
//                    switch (max) {
//                        case 1:
//                            tableStyle.setColWidths(new int[]{650, 2000, 2000, 850, 2200, 2100, 1200});
//                            break;
//                        case 2:
//                            tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 2100, 1200, 1200, 1200});
//                            break;
//                        case 3:
//                            tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 1500, 1000, 1000, 1000, 1200});
//                            break;
//                        case 4:
//                            tableStyle.setColWidths(new int[]{650, 1200, 1200, 850, 1400, 850, 850, 850, 850, 1200});
//                            break;
//                        case 5:
//                            tableStyle.setColWidths(new int[]{650, 1100, 1100, 850, 1350, 750, 750, 750, 750, 750, 1200});
//                            break;
//                    }
                    tableStyle.setWidth("10000");
                    tableStyle.setAlign(TableRowAlign.CENTER);
                    BorderStyle borderStyle = new BorderStyle();
@@ -2586,42 +2586,43 @@
                }
                tableRenderData.getRows().add(row);
            }
            if (!tableRenderData.getRows().isEmpty() && tableRenderData.getRows().size() != 3) {
            TableStyle tableStyle = new TableStyle();
            if (tableRenderData.getRows().size() != 3) {
                //设置样式
                TableStyle tableStyle = new TableStyle();
                for (int i = 1; i <= max; i++) {
                    // 根据减压那结果个数修改长度
                    switch (i) {
                        case 1:
                            tableStyle.setColWidths(new int[]{650, 2000, 2000, 850, 2200, 2100, 1200});
                            break;
                        case 2:
                            tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 2100, 1200, 1200, 1200});
                            break;
                        case 3:
                            tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 1500, 1000, 1000, 1000, 1200});
                            break;
                        case 4:
                            tableStyle.setColWidths(new int[]{650, 1200, 1200, 850, 1400, 850, 850, 850, 850, 1200});
                            break;
                        case 5:
                            tableStyle.setColWidths(new int[]{650, 1100, 1100, 850, 1350, 750, 750, 750, 750, 750, 1200});
                            break;
                    }
                }
                tableStyle.setWidth("10000");
                tableStyle.setAlign(TableRowAlign.CENTER);
                BorderStyle borderStyle = new BorderStyle();
                borderStyle.setColor("000000");
                borderStyle.setType(XWPFTable.XWPFBorderType.THICK);
                borderStyle.setSize(14);
                tableStyle.setLeftBorder(borderStyle);
                tableStyle.setTopBorder(borderStyle);
                tableStyle.setRightBorder(borderStyle);
                tableStyle.setBottomBorder(borderStyle);
                tableRenderData.setTableStyle(tableStyle);
                tables1.add(tableRenderData);
//                for (int i = 1; i <= max; i++) {
//                }
                // 根据检验结果个数修改长度
                tableStyle.setColWidths(calcTableColWidths(max));
//                switch (max) {
//                    case 1:
//                        tableStyle.setColWidths(new int[]{650, 2000, 2000, 850, 2200, 2100, 1200});
//                        break;
//                    case 2:
//                        tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 2100, 1200, 1200, 1200});
//                        break;
//                    case 3:
//                        tableStyle.setColWidths(new int[]{650, 1400, 1400, 850, 1500, 1000, 1000, 1000, 1200});
//                        break;
//                    case 4:
//                        tableStyle.setColWidths(new int[]{650, 1200, 1200, 850, 1400, 850, 850, 850, 850, 1200});
//                        break;
//                    case 5:
//                        tableStyle.setColWidths(new int[]{650, 1100, 1100, 850, 1350, 750, 750, 750, 750, 750, 1200});
//                        break;
//                }
            }
            tableStyle.setWidth("10000");
            tableStyle.setAlign(TableRowAlign.CENTER);
            BorderStyle borderStyle = new BorderStyle();
            borderStyle.setColor("000000");
            borderStyle.setType(XWPFTable.XWPFBorderType.THICK);
            borderStyle.setSize(14);
            tableStyle.setLeftBorder(borderStyle);
            tableStyle.setTopBorder(borderStyle);
            tableStyle.setRightBorder(borderStyle);
            tableStyle.setBottomBorder(borderStyle);
            tableRenderData.setTableStyle(tableStyle);
            tables1.add(tableRenderData);
            tables1.forEach(table -> {
                Map<String, Object> tableMap = new HashMap<>();
                tableMap.put("table", table);
@@ -2830,6 +2831,45 @@
    }
    /**
     * 计算表格列宽度
     * @param max 最大检验个数
     * @return
     */
    private static int[] calcTableColWidths(int max){
        int[] colWidths = null;
        switch (max) {
            case 1:
                colWidths = new int[]{650, 2000, 2000, 850, 2200, 2100, 1200};
                break;
            case 2:
                colWidths = new int[]{650, 1400, 1400, 850, 2100, 1200, 1200, 1200};
                break;
            case 3:
                colWidths = new int[]{650, 1400, 1400, 850, 1500, 1000, 1000, 1000, 1200};
                break;
            case 4:
                colWidths = new int[]{650, 1200, 1200, 850, 1400, 850, 850, 850, 850, 1200};
                break;
            case 5:
                colWidths = new int[]{650, 1100, 1100, 850, 1350, 750, 750, 750, 750, 750, 1200};
                break;
        }
        if(ObjectUtils.isNull(colWidths)){
            List<Integer> defaultColWidths = new ArrayList<>(Arrays.asList(650, 1100, 1100, 850, 1350));
            int totalWidth = 3000;//总宽度
            int byOneWidth = totalWidth/max;//每一个的宽度
            int realWidth = 0;//实际宽度
            for (int i = 0; i < max; i++) {
                realWidth+=byOneWidth;
                defaultColWidths.add(byOneWidth);
            }
            defaultColWidths.add(1200+(totalWidth-realWidth));
            return defaultColWidths.stream().mapToInt(Integer::intValue).toArray();
        }
        return colWidths;
    }
    /**
     * 调整高度
     * @param row
     * @param rowHeight
@@ -2844,9 +2884,9 @@
        // 获取检测内容判断是否超出
        if (StringUtils.isNotBlank(dataText) && dataText.contains("@")) {
            double number = 1;
            double chinaLength = 0;
            double englishLength = 0;
            double valueLength = 0;
            double chinaLength = 14;
            double englishLength = 28;
            double valueLength = 6;
            // 根据线芯个数判断距离
            switch (max) {
                case 1:
@@ -3712,7 +3752,6 @@
        // 检验项分类      检验项  检验子项
        Map<String, LinkedHashMap<String, List<String>>> errorClassItemMapCn = new LinkedHashMap<>();
        Map<String, LinkedHashMap<String, List<String>>> errorClassItemMapEn = new LinkedHashMap<>();
        // 中间检测值添加
        for (int i = 0; i < sampleList.size(); i++) {
            SampleProductExportDto sample = sampleList.get(i);
@@ -3793,7 +3832,9 @@
            // 判断是否有电缆标识map
            if (CollectionUtils.isNotEmpty(sample.getCableTagValueMap())) {
                sample.setLastValueList(new ArrayList<>(sample.getCableTagValueMap().values()));
                TreeMap<String, String> cableTagValues = new TreeMap<>(Comparator.comparingInt(cableTags::indexOf));
                cableTagValues.putAll(sample.getCableTagValueMap());
                sample.setLastValueList(new ArrayList<>(cableTagValues.values()));
            }
            if (CollectionUtils.isNotEmpty(sample.getCableTagResultMap())) {
                sample.setInsResultList(new ArrayList<>(sample.getCableTagResultMap().values()));