2026-06-03 c7d92d01b02f6b26b17dc77b217f0ffe39615ebe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package com.ruoyi.util;
 
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateExceptionHandler;
 
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
 
public class TestReportDocGenerator {
 
    public static void main(String[] args) throws Exception {
        generateTestReportDoc();
    }
 
    public static void generateTestReportDoc() throws Exception {
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_32);
        cfg.setClassForTemplateLoading(TestReportDocGenerator.class, "/static");
        cfg.setDefaultEncoding("UTF-8");
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
 
        Map<String, Object> data = new HashMap<>();
 
        // 项目基本信息
        data.put("projectName", "产品库存管理系统");
        data.put("projectVersion", "V1.0");
        data.put("docDate", "2026年6月");
 
        // 测试计划概述
        data.put("testScope", "覆盖库存管理、采购销售、质检设备、人事协同、AI智能化等全部功能模块");
        data.put("testMethodology", "黑盒测试 + 白盒测试 + 自动化测试 + 性能测试");
        data.put("testCycle", "2026年5月20日 - 2026年6月30日");
        data.put("testEnv", "测试环境:Windows Server 2022 / JDK 25 / MySQL 8.0 / Redis 7.0");
 
        // 测试用例
        List<Map<String, String>> testCases = new ArrayList<>();
        testCases.add(createTestCase("TC-001", "登录模块", "用户名密码正确登录", "登录成功跳转主页", "登录成功", "通过", "王XX"));
        testCases.add(createTestCase("TC-002", "登录模块", "用户名错误登录", "提示用户不存在", "提示正确", "通过", "刘XX"));
        testCases.add(createTestCase("TC-003", "登录模块", "密码错误连续5次", "账号锁定30分钟", "锁定成功", "通过", "刘XX"));
        testCases.add(createTestCase("TC-004", "登录模块", "空用户名登录", "提示用户名为空", "提示正确", "通过", "刘XX"));
        testCases.add(createTestCase("TC-005", "库存管理", "采购入库-正常数据", "入库成功,库存增加", "入库成功", "通过", "王XX"));
        testCases.add(createTestCase("TC-006", "库存管理", "采购入库-缺少必填项", "提示必填字段", "提示正确", "通过", "刘XX"));
        testCases.add(createTestCase("TC-007", "库存管理", "销售出库-正常数据", "出库成功,库存减少", "出库成功", "通过", "王XX"));
        testCases.add(createTestCase("TC-008", "库存管理", "销售出库-库存不足", "提示库存不足", "提示正确", "通过", "刘XX"));
        testCases.add(createTestCase("TC-009", "库存管理", "库存盘点-差异报告", "生成差异报告", "报告正确", "通过", "王XX"));
        testCases.add(createTestCase("TC-010", "库存管理", "库存预警-下限触发", "自动生成预警通知", "通知已发送", "通过", "王XX"));
        testCases.add(createTestCase("TC-011", "采购管理", "创建采购订单", "订单创建成功", "创建成功", "通过", "赵XX"));
        testCases.add(createTestCase("TC-012", "采购管理", "采购审批流程", "逐级审批通过", "审批正常", "通过", "赵XX"));
        testCases.add(createTestCase("TC-013", "采购管理", "供应商信息维护", "信息更新成功", "更新成功", "通过", "赵XX"));
        testCases.add(createTestCase("TC-014", "销售管理", "创建销售订单", "订单创建成功", "创建成功", "通过", "赵XX"));
        testCases.add(createTestCase("TC-015", "销售管理", "销售报价单生成", "报价单生成PDF", "生成成功", "通过", "赵XX"));
        testCases.add(createTestCase("TC-016", "质检管理", "来料检验-合格品", "检验通过入库", "检验正确", "通过", "刘XX"));
        testCases.add(createTestCase("TC-017", "质检管理", "不合格品处理流程", "触发不合格处理流程", "流程正确", "通过", "刘XX"));
        testCases.add(createTestCase("TC-018", "设备管理", "设备台账录入", "设备信息保存成功", "保存成功", "通过", "王XX"));
        testCases.add(createTestCase("TC-019", "设备管理", "保养计划创建", "计划创建成功", "创建成功", "通过", "王XX"));
        testCases.add(createTestCase("TC-020", "设备管理", "保养验收确认", "验收通过记录归档", "验收成功", "进行中", "王XX"));
        testCases.add(createTestCase("TC-021", "人事管理", "员工入职登记", "员工信息入库", "登记成功", "通过", "赵XX"));
        testCases.add(createTestCase("TC-022", "人事管理", "合同到期提醒", "自动发送提醒通知", "通知已发送", "通过", "赵XX"));
        testCases.add(createTestCase("TC-023", "AI模块", "智能问答-库存查询", "返回正确库存信息", "返回正确", "通过", "孙XX"));
        testCases.add(createTestCase("TC-024", "AI模块", "库存预测准确性", "预测误差小于15%", "误差12%", "通过", "孙XX"));
        testCases.add(createTestCase("TC-025", "AI模块", "OCR文档识别", "识别准确率&gt;95%", "准确率96.5%", "通过", "孙XX"));
        testCases.add(createTestCase("TC-026", "AI模块", "语音录入功能", "识别准确率&gt;90%", "准确率88%", "进行中", "孙XX"));
        testCases.add(createTestCase("TC-027", "系统管理", "用户权限配置", "权限生效且隔离", "权限正确", "通过", "刘XX"));
        testCases.add(createTestCase("TC-028", "系统管理", "操作日志审计", "关键操作全记录", "记录完整", "通过", "刘XX"));
        testCases.add(createTestCase("TC-029", "性能测试", "100并发用户登录", "响应时间&lt;3秒", "平均1.8秒", "通过", "刘XX"));
        testCases.add(createTestCase("TC-030", "性能测试", "百万级数据查询", "查询时间&lt;2秒", "0.9秒", "通过", "刘XX"));
        data.put("testCases", testCases);
 
        // 测试进度跟踪
        List<Map<String, String>> progress = new ArrayList<>();
        progress.add(createProgress("2026-05-20", "登录模块、库存入库", "8", "8", "100%", "已完成第一轮"));
        progress.add(createProgress("2026-05-21", "库存出库、库存盘点", "10", "9", "90%", "库存盘点待回归"));
        progress.add(createProgress("2026-05-22", "库存预警、采购订单", "8", "8", "100%", ""));
        progress.add(createProgress("2026-05-23", "销售管理、供应商管理", "10", "8", "80%", "供应商审批流程待测"));
        progress.add(createProgress("2026-05-24", "质检管理全流程", "6", "6", "100%", ""));
        progress.add(createProgress("2026-05-25", "设备台账、保养计划", "6", "4", "67%", "保养验收功能开发中"));
        progress.add(createProgress("2026-05-26", "人事管理、合同管理", "8", "6", "75%", "合同到期提醒待验证"));
        progress.add(createProgress("2026-05-27", "AI智能问答、OCR识别", "6", "5", "83%", "语音录入准确率待优化"));
        progress.add(createProgress("2026-05-28", "系统管理、性能测试", "8", "6", "75%", "性能测试进行中"));
        progress.add(createProgress("2026-05-29", "全模块回归测试", "30", "25", "83%", "3个用例待修复后重测"));
        progress.add(createProgress("2026-05-30", "缺陷修复验证", "12", "10", "83%", "2个低优先级缺陷延后处理"));
        data.put("progress", progress);
 
        // 缺陷跟踪
        List<Map<String, String>> defects = new ArrayList<>();
        defects.add(createDefect("BUG-001", "库存查询响应时间超过5秒", "严重", "王XX", "已修复", "2026-05-22"));
        defects.add(createDefect("BUG-002", "入库批号重复校验失效", "严重", "王XX", "已修复", "2026-05-22"));
        defects.add(createDefect("BUG-003", "采购订单金额精度丢失", "一般", "赵XX", "已修复", "2026-05-23"));
        defects.add(createDefect("BUG-004", "前端分页组件显示异常", "轻微", "陈XX", "已修复", "2026-05-24"));
        defects.add(createDefect("BUG-005", "AI智能问答接口超时", "严重", "孙XX", "修复中", "2026-05-27"));
        defects.add(createDefect("BUG-006", "设备保养提醒定时任务未触发", "一般", "王XX", "待处理", "2026-05-28"));
        defects.add(createDefect("BUG-007", "Excel导出大数据量内存溢出", "一般", "王XX", "修复中", "2026-05-29"));
        defects.add(createDefect("BUG-008", "语音录入方言识别率低", "轻微", "孙XX", "待处理", "2026-05-30"));
        defects.add(createDefect("BUG-009", "多用户同时盘点导致数据不一致", "严重", "王XX", "待处理", "2026-05-30"));
        defects.add(createDefect("BUG-010", "移动端页面适配异常", "轻微", "陈XX", "待处理", "2026-05-30"));
        data.put("defects", defects);
 
        // 测试统计
        data.put("totalCases", "80");
        data.put("passedCases", "68");
        data.put("failedCases", "3");
        data.put("inProgressCases", "5");
        data.put("blockedCases", "4");
        data.put("passRate", "85.0%");
        data.put("totalDefects", "10");
        data.put("fixedDefects", "4");
        data.put("openDefects", "4");
        data.put("inProgressDefects", "2");
        data.put("criticalDefects", "3");
        data.put("majorDefects", "3");
        data.put("minorDefects", "4");
 
        // 测试结论
        data.put("testConclusion", "系统整体功能完整,核心业务流程通过测试。存在3个严重缺陷待修复:AI接口超时、盘点并发数据不一致、Excel导出内存溢出。建议修复严重缺陷后安排第二轮回归测试,再进入上线流程。");
        data.put("releaseSuggestion", "有条件通过,修复严重缺陷后可上线");
 
        // 待办事项
        List<Map<String, String>> actionItems = new ArrayList<>();
        actionItems.add(createActionItem("1", "修复AI智能问答接口超时问题", "孙XX", "2026-06-02"));
        actionItems.add(createActionItem("2", "修复盘点并发数据一致性问题", "王XX", "2026-06-03"));
        actionItems.add(createActionItem("3", "修复Excel大数据量导出内存溢出", "王XX", "2026-06-03"));
        actionItems.add(createActionItem("4", "完成语音录入方言识别优化", "孙XX", "2026-06-05"));
        actionItems.add(createActionItem("5", "完成第二轮全量回归测试", "刘XX", "2026-06-08"));
        actionItems.add(createActionItem("6", "输出最终测试报告", "刘XX", "2026-06-10"));
        data.put("actionItems", actionItems);
 
        // 加载模板并生成
        Template template = cfg.getTemplate("测试报告.xml");
        StringWriter out = new StringWriter();
        template.process(data, out);
 
        // 保存为docx
        String outputPath = "D:/牛马/文档/测试报告.docx";
        File outputFile = new File(outputPath);
        outputFile.getParentFile().mkdirs();
        try (FileOutputStream fos = new FileOutputStream(outputFile);
             OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
            osw.write(out.toString());
        }
 
        System.out.println("测试报告生成成功: " + outputPath);
    }
 
    private static Map<String, String> createTestCase(String no, String module, String content,
                                                       String expected, String actual, String status, String tester) {
        Map<String, String> map = new HashMap<>();
        map.put("no", no);
        map.put("module", module);
        map.put("content", content);
        map.put("expected", expected);
        map.put("actual", actual);
        map.put("status", status);
        map.put("tester", tester);
        return map;
    }
 
    private static Map<String, String> createProgress(String date, String content, String total,
                                                       String completed, String rate, String remark) {
        Map<String, String> map = new HashMap<>();
        map.put("date", date);
        map.put("content", content);
        map.put("total", total);
        map.put("completed", completed);
        map.put("rate", rate);
        map.put("remark", remark);
        return map;
    }
 
    private static Map<String, String> createDefect(String no, String desc, String severity,
                                                     String owner, String status, String deadline) {
        Map<String, String> map = new HashMap<>();
        map.put("no", no);
        map.put("desc", desc);
        map.put("severity", severity);
        map.put("owner", owner);
        map.put("status", status);
        map.put("deadline", deadline);
        return map;
    }
 
    private static Map<String, String> createActionItem(String no, String content, String owner, String deadline) {
        Map<String, String> map = new HashMap<>();
        map.put("no", no);
        map.put("content", content);
        map.put("owner", owner);
        map.put("deadline", deadline);
        return map;
    }
}