zhuo
2025-02-25 90d6a03c642d174475c63f136b4aa0a1a91902bf
报告生成调整
已修改13个文件
383 ■■■■ 文件已修改
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessComplainController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessDealController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessMethodSearchNewController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessMethodVerifyController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessReportController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessTotalSampleController.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessTotaldealController.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/mapper/ProcessReportMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java 333 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/mapper/InsOrderMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspect-server/src/main/resources/static/report-template.docx 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessComplainController.java
@@ -48,7 +48,7 @@
    }
    @ApiOperation(value = "投诉详情")
    @PostMapping("/getProcessComplain")
    @GetMapping("/getProcessComplain")
    public Result getProcessComplain(Long id) {
        return Result.success(processComplainService.getProcessComplain(id));
    }
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessDealController.java
@@ -29,7 +29,7 @@
    private ProcessDealService processDealService;
    @ApiOperation(value = "查询检测或校准物品的处置详情")
    @PostMapping("/pageProcessDeal")
    @GetMapping("/pageProcessDeal")
    public Result pageProcessDeal(ProcessDeal processDeal, Page page) throws Exception {
        return Result.success(processDealService.pageProcessDeal(page, processDeal));
    }
@@ -53,7 +53,7 @@
    }
    @ApiOperation(value = "查看检测或校准物品的处置")
    @PostMapping("/getProcessDeal")
    @GetMapping("/getProcessDeal")
    public Result getProcessDeal(Integer id) {
        return Result.success(processDealService.getById(id));
    }
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessMethodSearchNewController.java
@@ -78,7 +78,7 @@
     * @return
     */
    @ApiOperation(value = "导入标准查新")
    @GetMapping("/importMethodSearchNew")
    @PostMapping("/importMethodSearchNew")
    public Result importMethodSearchNew(MultipartFile file){
        return Result.success(processMethodSearchNewService.importMethodSearchNew(file));
    }
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessMethodVerifyController.java
@@ -47,7 +47,7 @@
     * @return
     */
    @ApiOperation(value = "标准方法更新验证列表")
    @PostMapping("/pagesMethodVerify")
    @GetMapping("/pagesMethodVerify")
    public Result<IPage<ProcessMethodVerify>> pagesMethodVerify(ProcessMethodVerifyDto methodVerifyDto,Page page) throws Exception {
        return Result.success(processMethodVerifyService.pagesMethodVerify(page, methodVerifyDto));
    }
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessReportController.java
@@ -7,10 +7,7 @@
import com.ruoyi.process.service.ProcessReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
@@ -32,7 +29,7 @@
    private ProcessReportService processReportService;
    @ApiOperation(value = "查询检验报告发放登记列表")
    @PostMapping("/pageProcessReport")
    @GetMapping("/pageProcessReport")
    public Result pageProcessReport(ProcessReport processReport , Page page) throws Exception {
        return Result.success(processReportService.pageProcessReport(page, processReport));
    }
@@ -44,13 +41,13 @@
    }
    @ApiOperation(value = "删除检验报告发放登记")
    @PostMapping("/delProcessReport")
    @DeleteMapping("/delProcessReport")
    public Result delProcessReport(Long id) {
        return Result.success(processReportService.removeById(id));
    }
    @ApiOperation(value = "查看检验报告发放登记详情")
    @PostMapping("/getProcessReport")
    @GetMapping("/getProcessReport")
    public Result getProcessReport(Long id)  {
        return Result.success(processReportService.getById(id));
    }
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessTotalSampleController.java
@@ -35,19 +35,24 @@
    @ApiOperation(value = "提交样品接收")
    @PostMapping("/submitProcessTotalSample")
    public Result submitProcessTotalSample(Integer id) {
    public Result submitProcessTotalSample(@RequestBody Map<String, Object> param) {
        Integer id = (Integer) param.get("id");
        return Result.success(processTotalSampleService.submitProcessTotalSample(id));
    }
    @ApiOperation(value = "审核样品接收")
    @PostMapping("/checkProcessTotalSample")
    public Result checkProcessTotalSample(Integer id, String state) {
    public Result checkProcessTotalSample(@RequestBody Map<String, Object> param) {
        Integer id = (Integer) param.get("id");
        String state = (String) param.get("state");
        return Result.success(processTotalSampleService.checkProcessTotalSample(id, state));
    }
    @ApiOperation(value = "批准样品接收")
    @PostMapping("/ratifyProcessTotalSample")
    public Result ratifyProcessTotalSample(Integer id,String state) {
    public Result ratifyProcessTotalSample(@RequestBody Map<String, Object> param) {
        Integer id = (Integer) param.get("id");
        String state = (String) param.get("state");
        return Result.success(processTotalSampleService.ratifyProcessTotalSample(id,state));
    }
cnas-process/src/main/java/com/ruoyi/process/controller/ProcessTotaldealController.java
@@ -35,19 +35,24 @@
    @ApiOperation(value = "提交检测或校准物品的处置")
    @PostMapping("/submitProcessTotaldeal")
    public Result submitProcessTotaldeal(Integer id) {
    public Result submitProcessTotaldeal(@RequestBody Map<String, Integer> param) {
        Integer id = param.get("id");
        return Result.success(processTotaldealService.submitProcessTotaldeal(id));
    }
    @ApiOperation(value = "审核检测或校准物品的处置")
    @PostMapping("/checkProcessTotaldeal")
    public Result checkProcessTotaldeal(Integer id, String state) {
    public Result checkProcessTotaldeal(@RequestBody Map<String, Object> param) {
        Integer id = (Integer) param.get("id");
        String state = (String) param.get("state");
        return Result.success(processTotaldealService.checkProcessTotaldeal(id, state));
    }
    @ApiOperation(value = "批准检测或校准物品的处置")
    @PostMapping("/ratifyProcessTotaldeal")
    public Result ratifyProcessTotaldeal(Integer id,String state) {
    public Result ratifyProcessTotaldeal(@RequestBody Map<String, Object> param) {
        Integer id = (Integer) param.get("id");
        String state = (String) param.get("state");
        return Result.success(processTotaldealService.ratifyProcessTotaldeal(id,state));
    }
cnas-process/src/main/java/com/ruoyi/process/mapper/ProcessReportMapper.java
@@ -21,5 +21,5 @@
    IPage<ProcessReport> pageProcessReport(Page page, @Param("ew") QueryWrapper<ProcessReport> queryWrappers);
    List<ProcessReport> getIds(List<Integer> ids);
    List<ProcessReport> getIds(@Param("ids") List<Integer> ids);
}
inspect-server/src/main/java/com/ruoyi/inspect/mapper/InsOrderMapper.java
@@ -38,7 +38,7 @@
    List<CostStatisticsDto> selectCostStatistics2(@Param("ew") QueryWrapper<CostStatisticsDto> ew);
    List<Map<String, String>> selectDeviceList(@Param("names") Set<String> names);
    List<Map<String, String>> selectDeviceList(@Param("managementNumbers") Set<String> managementNumbers);
    List<SampleDefectsFatherVo> selectSampleDefects(Page page, @Param("inspectionItems") String inspectionItems, @Param("orderNumber") String orderNumber);
    Long getCount(@Param("inspectionItems") String inspectionItems, @Param("orderNumber") String orderNumber);
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -42,6 +42,7 @@
import com.ruoyi.inspect.mapper.*;
import com.ruoyi.inspect.pojo.*;
import com.ruoyi.inspect.service.*;
import com.ruoyi.inspect.util.HackLoopTableRenderPolicy;
import com.ruoyi.inspect.vo.InsOrderPlanTaskSwitchVo;
import com.ruoyi.inspect.vo.InsOrderPlanVO;
import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper;
@@ -1880,6 +1881,8 @@
                    put("seal1", null);
                }});
        try {
            // 修改换行和合并问题
            updaeMerge(template.getXWPFDocument(), true);
            String name = insReport.getCode().replace("/", "") + "-J.docx";
            template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
            insReport.setUrl("/word/" + name);
@@ -1894,8 +1897,6 @@
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        // 修改换行和合并问题
        updaeMerge(insReport, null, true);
    }
    /**
@@ -2263,10 +2264,19 @@
        tables.forEach(table -> {
            table.put("tableSize", tables.size() + 1);
        });
        // 设备信息
        List<Map<String, String>> deviceList = null;
        if (deviceSet.size() != 0) {
        if (CollectionUtils.isNotEmpty(deviceSet)) {
            deviceList = insOrderMapper.selectDeviceList(deviceSet);
        }
        if (CollectionUtils.isNotEmpty(deviceList)) {
            int count = 1;
            for (Map<String, String> stringMap : deviceList) {
                stringMap.put("index", String.valueOf(count));
                count++;
            }
        }
        Map<String, String> codeStr = new HashMap<>();
        codeStr.put("报告编号", insReport.getCode());
        codeStr.put("样品名称", insOrder.getSample());
@@ -2274,7 +2284,6 @@
        codeStr.put("发放日期", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
        String modelStr = CollUtil.join(models, "\n");
        String finalModelStr = modelStr;
        // 检测类型
        String orderType = null;
@@ -2288,11 +2297,10 @@
        String formType = iSysDictTypeService.selectLabelByDict(DictDataConstants.FORM_TYPE, insOrder.getFormType());
        // 样品状态
        String sampleStatus = iSysDictTypeService.selectLabelByDict(DictDataConstants.SAMPLE_STATUS_LIST, insOrder.getSampleStatus());;
        String sampleStatus = iSysDictTypeService.selectLabelByDict(DictDataConstants.SAMPLE_STATUS_LIST, insOrder.getSampleStatus());
        ;
        ConfigureBuilder builder = Configure.builder();
        builder.useSpringEL(true);
        List<Map<String, String>> finalDeviceList = deviceList;
        // 公司信息
        Custom custom = customMapper.selectById(insOrder.getCompanyId());
        // 查询判断是否有不判定项目,和全都是判定项
@@ -2382,12 +2390,18 @@
        environment = (ObjectUtils.isNotEmpty(insOrder.getTemperature()) ? insOrder.getTemperature() + "℃ " : "") + (ObjectUtils.isNotEmpty(insOrder.getHumidity()) ? insOrder.getHumidity() + "%" : "");
        String finalEnvironment = environment;
        LocalDateTime finalSendTime = sendTime;
        String finalResultCh = resultCh;
        String finalResultEn = resultEn;
        String finalOrderType = orderType;
        List<Map<String, String>> finalDeviceList = deviceList;
        String finalModelStr = modelStr;
        InputStream inputStream = this.getClass().getResourceAsStream("/static/report-template.docx");
        XWPFTemplate template = XWPFTemplate.compile(inputStream, builder.build()).render(
        Configure configure = Configure.builder()
                .bind("deviceList", new HackLoopTableRenderPolicy())
                .build();
        XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render(
                new HashMap<String, Object>() {{
                    put("order", insOrder);
                    put("report", insReport);
@@ -2422,6 +2436,8 @@
                    put("sampleStatus", sampleStatus);
                }});
        try {
            // 修改换行和合并问题
            updaeMerge(template.getXWPFDocument(), false);
            String name = insReport.getCode().replace("/", "") + ".docx";
            template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl + "/" + name)));
            insReport.setUrl("/word/" + name);
@@ -2434,8 +2450,6 @@
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        // 修改换行和合并问题
        updaeMerge(insReport, deviceList, false);
    }
    /**
@@ -2506,188 +2520,165 @@
    /**
     * 合并单元格
     * @param insReport
     * @param deviceList
     */
    private void updaeMerge(InsReport insReport, List<Map<String, String>> deviceList, boolean isSmall) {
    private void updaeMerge(XWPFDocument document, boolean isSmall) {
        // 处理合并单元格的问题
        String path = wordUrl + insReport.getUrl().replaceFirst("/word", "");
        try {
            // 获取文档中的所有表格
            FileInputStream stream = new FileInputStream(path);
            XWPFDocument document = new XWPFDocument(stream);
            List<XWPFTable> xwpfTables = document.getTables();
            // 遍历表格,但跳过第一个表格(如果deviceList为null,则额外跳过第二个)
            for (int i = 1; i < xwpfTables.size() - (deviceList == null ? 1 : 2); i++) {
                // 创建一个HashSet来存储唯一的字符串(这里基于"∑"分割后的第二部分)
                Set<String> set1 = new HashSet<>();
                // 创建一个HashMap来存储每个唯一字符串及其对应的单元格位置信息
                Map<String, Map<String, Integer>> maps = new HashMap<>();
                // 遍历当前表格的所有行
                for (int j = 0; j < xwpfTables.get(i).getRows().size(); j++) {
                    // 遍历当前行的所有单元格
                    for (int k = 0; k < xwpfTables.get(i).getRows().get(j).getTableCells().size(); k++) {
                        // 检查单元格文本中是否包含"∑"
                        if (xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().indexOf("∑") > -1) {
                            String[] split = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("∑");
                            // 如果分割后的第二部分是新的(即之前未出现过),则添加到set1并创建位置信息map
                            if (set1.add(split[1])) {
                                Map<String, Integer> map = new HashMap<>();
                                // 存储起始行、起始列、结束行(当前行)、结束列(当前列)
                                map.put("sr", j);
                                map.put("sc", k);
                                map.put("er", j + 0);
                                map.put("ec", k + 0);
                                maps.put(split[1], map);
                            } else {
                                // 如果已存在,则更新结束行或结束列
                                Map<String, Integer> map1 = maps.get(split[1]);
                                if (j == map1.get("sr")) {
                                    map1.put("ec", map1.get("ec") + 1);
                                } else if (k == map1.get("sc")) {
                                    map1.put("er", map1.get("er") + 1);
                                }
        // 获取文档中的所有表格
        List<XWPFTable> xwpfTables = document.getTables();
        // 遍历表格
        for (int i = 1; i < xwpfTables.size(); i++) {
            // 创建一个HashSet来存储唯一的字符串(这里基于"∑"分割后的第二部分)
            Set<String> set1 = new HashSet<>();
            // 创建一个HashMap来存储每个唯一字符串及其对应的单元格位置信息
            Map<String, Map<String, Integer>> maps = new HashMap<>();
            // 遍历当前表格的所有行
            for (int j = 0; j < xwpfTables.get(i).getRows().size(); j++) {
                // 遍历当前行的所有单元格
                for (int k = 0; k < xwpfTables.get(i).getRows().get(j).getTableCells().size(); k++) {
                    // 检查单元格文本中是否包含"∑"
                    if (xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().indexOf("∑") > -1) {
                        String[] split = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("∑");
                        // 如果分割后的第二部分是新的(即之前未出现过),则添加到set1并创建位置信息map
                        if (set1.add(split[1])) {
                            Map<String, Integer> map = new HashMap<>();
                            // 存储起始行、起始列、结束行(当前行)、结束列(当前列)
                            map.put("sr", j);
                            map.put("sc", k);
                            map.put("er", j + 0);
                            map.put("ec", k + 0);
                            maps.put(split[1], map);
                        } else {
                            // 如果已存在,则更新结束行或结束列
                            Map<String, Integer> map1 = maps.get(split[1]);
                            if (j == map1.get("sr")) {
                                map1.put("ec", map1.get("ec") + 1);
                            } else if (k == map1.get("sc")) {
                                map1.put("er", map1.get("er") + 1);
                            }
                            // 判断小高报告还是大报告
                            if (isSmall) {
                                // 获取单元格
                                XWPFTableCell cell = xwpfTables.get(i).getRows().get(j).getTableCells().get(k);
                                XWPFParagraph paragraph = cell.getParagraphArray(0);
                                String originalText = paragraph.getText();
                                String newText = originalText.split("∑")[0];
                                List<XWPFRun> runs = paragraph.getRuns();
                                for (XWPFRun run : runs) {
                                    run.setText("", 0); // 清空 run 中的文本
                                }
                                if (!runs.isEmpty()) {
                                    XWPFRun run = runs.get(0);
                                    run.setText(newText);
                                    // 复制样式
                                    run.setFontFamily(paragraph.getRuns().get(0).getFontFamily());
                                    run.setFontSize(paragraph.getRuns().get(0).getFontSize());
                                    run.setBold(paragraph.getRuns().get(0).isBold());
                                    run.setItalic(paragraph.getRuns().get(0).isItalic());
                                    run.setUnderline(paragraph.getRuns().get(0).getUnderline());
                                    run.setColor(paragraph.getRuns().get(0).getColor());
                                }
                                cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
                                paragraph.setAlignment(ParagraphAlignment.CENTER);
                            } else {
                                // 移除包含"∑"的段落,并重新设置单元格文本和样式
                                String str = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("∑")[0];
                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setText(str);
                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
                                xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getParagraphArray(0).setAlignment(ParagraphAlignment.CENTER);
                        }
                        // 判断小高报告还是大报告
                        if (isSmall) {
                            // 获取单元格
                            XWPFTableCell cell = xwpfTables.get(i).getRows().get(j).getTableCells().get(k);
                            XWPFParagraph paragraph = cell.getParagraphArray(0);
                            String originalText = paragraph.getText();
                            String newText = originalText.split("∑")[0];
                            List<XWPFRun> runs = paragraph.getRuns();
                            for (XWPFRun run : runs) {
                                run.setText("", 0); // 清空 run 中的文本
                            }
                            if (!runs.isEmpty()) {
                                XWPFRun run = runs.get(0);
                                run.setText(newText);
                                // 复制样式
                                run.setFontFamily(paragraph.getRuns().get(0).getFontFamily());
                                run.setFontSize(paragraph.getRuns().get(0).getFontSize());
                                run.setBold(paragraph.getRuns().get(0).isBold());
                                run.setItalic(paragraph.getRuns().get(0).isItalic());
                                run.setUnderline(paragraph.getRuns().get(0).getUnderline());
                                run.setColor(paragraph.getRuns().get(0).getColor());
                            }
                            cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
                            paragraph.setAlignment(ParagraphAlignment.CENTER);
                        } else {
                            // 移除包含"∑"的段落,并重新设置单元格文本和样式
                            String str = xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getText().split("∑")[0];
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setText(str);
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
                            xwpfTables.get(i).getRows().get(j).getTableCells().get(k).getParagraphArray(0).setAlignment(ParagraphAlignment.CENTER);
                        }
                    }
                }
            }
                // 单元格排序, 避免格式错乱
                List<Map.Entry<String, Map<String, Integer>>> entries = new ArrayList<>(maps.entrySet());
                entries.sort((o1, o2) -> o1.getValue().get("sc") - o2.getValue().get("sc"));
            // 单元格排序, 避免格式错乱
            List<Map.Entry<String, Map<String, Integer>>> entries = new ArrayList<>(maps.entrySet());
            entries.sort((o1, o2) -> o1.getValue().get("sc") - o2.getValue().get("sc"));
                // 按照顺序添加进集合
                List<String> list = new ArrayList<>();
                for (Map.Entry<String, Map<String, Integer>> entry : entries) {
                    list.add(entry.getKey());
                }
            // 按照顺序添加进集合
            List<String> list = new ArrayList<>();
            for (Map.Entry<String, Map<String, Integer>> entry : entries) {
                list.add(entry.getKey());
            }
                for (int a = list.size() - 1; a >= 0; a--) {
                    Map<String, Integer> v = maps.get(list.get(a));
                    for (int j = 0; j < v.get("er") - v.get("sr") + 1; j++) {
                        if (v.get("ec") > v.get("sc")) {
                            try {
                                TableTools.mergeCellsHorizonal(xwpfTables.get(i), v.get("sr") + j, v.get("sc"), v.get("ec"));
                            } catch (Exception e) {
                            }
                        }
                    }
                    if (v.get("er") > v.get("sr")) {
            for (int a = list.size() - 1; a >= 0; a--) {
                Map<String, Integer> v = maps.get(list.get(a));
                for (int j = 0; j < v.get("er") - v.get("sr") + 1; j++) {
                    if (v.get("ec") > v.get("sc")) {
                        try {
                            TableTools.mergeCellsVertically(xwpfTables.get(i), v.get("sc"), v.get("sr"), v.get("er"));
                            TableTools.mergeCellsHorizonal(xwpfTables.get(i), v.get("sr") + j, v.get("sc"), v.get("ec"));
                        } catch (Exception e) {
                        }
                    }
                }
                if (v.get("er") > v.get("sr")) {
                    try {
                        TableTools.mergeCellsVertically(xwpfTables.get(i), v.get("sc"), v.get("sr"), v.get("er"));
                    } catch (Exception e) {
                    }
                }
            }
            FileOutputStream fileOutputStream = new FileOutputStream(path);
            document.write(fileOutputStream);
            fileOutputStream.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        //处理中英文换行的问题
        try {
            FileInputStream stream1 = new FileInputStream(path);
            XWPFDocument document1 = new XWPFDocument(stream1);
            List<XWPFTable> xwpfTables1 = document1.getTables();
            for (int i = 1; i < xwpfTables1.size() - (deviceList == null ? 1 : 2); i++) {
                for (int j = 0; j < xwpfTables1.get(i).getRows().size(); j++) {
                    for (int k = 0; k < xwpfTables1.get(i).getRows().get(j).getTableCells().size(); k++) {
                        if (xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText().contains("@")) {
                            if (isSmall) {
                                // 获取原有段落的第一个 XWPFRun
                                String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
                                XWPFParagraph oldParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getParagraphs().get(0);
                                XWPFRun oldRun = oldParagraph.getRuns().get(0);
                                // 保存原有样式
                                String fontFamily = oldRun.getFontFamily();
                                int fontSize = oldRun.getFontSize();
                                boolean isBold = oldRun.isBold();
                                boolean isItalic = oldRun.isItalic();
                                boolean isUnderline = oldRun.getUnderline() != UnderlinePatterns.NONE;
                                // 删除原有段落
                                xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
                                // 添加新段落
                                XWPFParagraph newParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
                                XWPFRun newRun = newParagraph.createRun();
                                // 应用保存的样式
                                newRun.setFontFamily(fontFamily);
                                newRun.setFontSize(fontSize);
                                newRun.setBold(isBold);
                                newRun.setItalic(isItalic);
                                if (isUnderline) {
                                    newRun.setUnderline(UnderlinePatterns.SINGLE);
                                }
                                // 设置新文本
                                String[] split = text.split("@");
                                newRun.setText(split[0]);
                                if (split.length > 1) {
                                    newRun.addBreak();
                                    newRun.setText(split[1]);
                                }
                                // 设置段落对齐方式
                                newParagraph.setAlignment(ParagraphAlignment.CENTER);
                            } else {
                                String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
                                String[] split = text.split("@");
                                xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
                                XWPFParagraph xwpfParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
                                XWPFRun run = xwpfParagraph.createRun();
                                run.setText(split[0]);
                                if (ObjectUtils.isNotNull(split[1])) {
                                    run.addBreak();
                                    run.setText(split[1]);
                                }
                                xwpfParagraph.setAlignment(ParagraphAlignment.CENTER);
        List<XWPFTable> xwpfTables1 = document.getTables();
        for (int i = 1; i < xwpfTables1.size(); i++) {
            for (int j = 0; j < xwpfTables1.get(i).getRows().size(); j++) {
                for (int k = 0; k < xwpfTables1.get(i).getRows().get(j).getTableCells().size(); k++) {
                    if (xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText().contains("@")) {
                        if (isSmall) {
                            // 获取原有段落的第一个 XWPFRun
                            String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
                            XWPFParagraph oldParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getParagraphs().get(0);
                            XWPFRun oldRun = oldParagraph.getRuns().get(0);
                            // 保存原有样式
                            String fontFamily = oldRun.getFontFamily();
                            int fontSize = oldRun.getFontSize();
                            boolean isBold = oldRun.isBold();
                            boolean isItalic = oldRun.isItalic();
                            boolean isUnderline = oldRun.getUnderline() != UnderlinePatterns.NONE;
                            // 删除原有段落
                            xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
                            // 添加新段落
                            XWPFParagraph newParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
                            XWPFRun newRun = newParagraph.createRun();
                            // 应用保存的样式
                            newRun.setFontFamily(fontFamily);
                            newRun.setFontSize(fontSize);
                            newRun.setBold(isBold);
                            newRun.setItalic(isItalic);
                            if (isUnderline) {
                                newRun.setUnderline(UnderlinePatterns.SINGLE);
                            }
                            // 设置新文本
                            String[] split = text.split("@");
                            newRun.setText(split[0]);
                            if (split.length > 1) {
                                newRun.addBreak();
                                newRun.setText(split[1]);
                            }
                            // 设置段落对齐方式
                            newParagraph.setAlignment(ParagraphAlignment.CENTER);
                        } else {
                            String text = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).getText();
                            String[] split = text.split("@");
                            xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).removeParagraph(0);
                            XWPFParagraph xwpfParagraph = xwpfTables1.get(i).getRows().get(j).getTableCells().get(k).addParagraph();
                            XWPFRun run = xwpfParagraph.createRun();
                            run.setText(split[0]);
                            if (ObjectUtils.isNotNull(split[1])) {
                                run.addBreak();
                                run.setText(split[1]);
                            }
                            xwpfParagraph.setAlignment(ParagraphAlignment.CENTER);
                        }
                    }
                }
            }
            FileOutputStream fileOutputStream1 = new FileOutputStream(path);
            document1.write(fileOutputStream1);
            fileOutputStream1.close();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
inspect-server/src/main/resources/mapper/InsOrderMapper.xml
@@ -241,7 +241,7 @@
        latest_traceability
        from device
        where device.management_number in
        <foreach collection="names" index="index" open="(" separator="," close=")" item="val">
        <foreach collection="managementNumbers" index="index" open="(" separator="," close=")" item="val">
            #{val}
        </foreach>
    </select>
inspect-server/src/main/resources/static/report-template.docx
Binary files differ
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
@@ -14,7 +14,6 @@
{
    public static void main(String[] args)
    {
//        System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(RuoYiApplication.class, args);
    }
}