2026-06-09 f818fa5eca223270f0656e0455c338ec1f2fac88
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
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 RequirementDocGenerator {
 
    public static void main(String[] args) throws Exception {
        generateRequirementDoc();
    }
 
    public static void generateRequirementDoc() throws Exception {
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_32);
        cfg.setClassForTemplateLoading(RequirementDocGenerator.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月");
 
        // 库存管理功能
        List<Map<String, String>> inventoryFeatures = new ArrayList<>();
        inventoryFeatures.add(createFeature("INV-001", "入库管理", "支持采购入库、生产入库、退货入库等多种入库方式,自动生成入库单号,支持批号管理"));
        inventoryFeatures.add(createFeature("INV-002", "出库管理", "支持销售出库、生产领料、调拨出库等,支持先进先出、批次出库策略"));
        inventoryFeatures.add(createFeature("INV-003", "库存盘点", "支持定期盘点、动态盘点,自动生成盘点差异报告"));
        inventoryFeatures.add(createFeature("INV-004", "库存预警", "支持库存上下限预警、效期预警、呆滞库存预警"));
        inventoryFeatures.add(createFeature("INV-005", "库存查询", "支持多维度库存查询,实时库存、历史库存、批次库存"));
        data.put("inventoryFeatures", inventoryFeatures);
 
        // 采购销售功能
        List<Map<String, String>> purchaseFeatures = new ArrayList<>();
        purchaseFeatures.add(createFeature("PUR-001", "采购台账", "采购申请、询价比价、采购订单、到货验收全流程管理"));
        purchaseFeatures.add(createFeature("PUR-002", "供应商管理", "供应商档案、资质管理、评估考核"));
        purchaseFeatures.add(createFeature("PUR-003", "销售报价", "客户管理、报价单、销售订单管理"));
        purchaseFeatures.add(createFeature("PUR-004", "发货管理", "发货单、物流跟踪、签收确认"));
        purchaseFeatures.add(createFeature("PUR-005", "售后管理", "退换货处理、售后服务记录"));
        data.put("purchaseFeatures", purchaseFeatures);
 
        // 质检设备功能
        List<Map<String, String>> qualityFeatures = new ArrayList<>();
        qualityFeatures.add(createFeature("QA-001", "质量检验", "来料检验、过程检验、成品检验,支持检验项目配置"));
        qualityFeatures.add(createFeature("QA-002", "不合格处理", "不合格品登记、处理流程、原因分析"));
        qualityFeatures.add(createFeature("QA-003", "设备台账", "设备档案、技术参数、附件管理"));
        qualityFeatures.add(createFeature("QA-004", "设备保养", "保养计划、保养任务、保养记录、验收确认"));
        qualityFeatures.add(createFeature("QA-005", "计量器具", "计量器具台账、检定计划、检定记录"));
        data.put("qualityFeatures", qualityFeatures);
 
        // 人事协同功能
        List<Map<String, String>> staffFeatures = new ArrayList<>();
        staffFeatures.add(createFeature("HR-001", "员工管理", "员工档案、入职离职、合同管理"));
        staffFeatures.add(createFeature("HR-002", "考勤管理", "打卡记录、请假审批、加班管理"));
        staffFeatures.add(createFeature("HR-003", "审批流程", "自定义审批流程、待办提醒、流程追溯"));
        staffFeatures.add(createFeature("HR-004", "会议室管理", "会议室预约、会议纪要、通知公告"));
        staffFeatures.add(createFeature("HR-005", "规章制度", "制度发布、阅读确认、文件归档"));
        data.put("staffFeatures", staffFeatures);
 
        // AI智能化功能
        List<Map<String, String>> aiFeatures = new ArrayList<>();
        aiFeatures.add(createFeature("AI-001", "智能客服", "基于大语言模型的智能问答,7x24小时在线服务"));
        aiFeatures.add(createFeature("AI-002", "库存预测", "基于历史数据的库存需求预测,智能补货建议"));
        aiFeatures.add(createFeature("AI-003", "销售预测", "机器学习驱动的销售趋势分析,辅助决策"));
        aiFeatures.add(createFeature("AI-004", "异常检测", "自动识别异常交易、异常库存变动"));
        aiFeatures.add(createFeature("AI-005", "智能文档", "OCR识别采购单、发货单,自动录入系统"));
        aiFeatures.add(createFeature("AI-006", "语音录入", "语音转文字,快速录入订单和库存信息"));
        data.put("aiFeatures", aiFeatures);
 
        // 用户角色
        List<Map<String, String>> userRoles = new ArrayList<>();
        userRoles.add(createRole("系统管理员", "系统维护和配置", "系统配置、用户管理、权限分配"));
        userRoles.add(createRole("仓库管理员", "库存日常管理", "入库、出库、盘点、库存查询"));
        userRoles.add(createRole("采购员", "采购业务处理", "采购申请、订单管理、供应商管理"));
        userRoles.add(createRole("销售员", "销售业务处理", "报价、订单、发货、售后"));
        userRoles.add(createRole("质检员", "质量检验工作", "检验任务、检验记录、不合格处理"));
        userRoles.add(createRole("设备管理员", "设备维护管理", "设备台账、保养计划、保养执行"));
        userRoles.add(createRole("人事专员", "人事行政管理", "员工档案、考勤、审批流程"));
        data.put("userRoles", userRoles);
 
        // 验收标准
        List<Map<String, String>> acceptCriteria = new ArrayList<>();
        acceptCriteria.add(createCriteria("1", "功能完整性", "所有需求功能开发完成并通过测试"));
        acceptCriteria.add(createCriteria("2", "性能达标", "响应时间、并发数满足性能需求"));
        acceptCriteria.add(createCriteria("3", "安全合规", "通过安全测试,符合数据安全规范"));
        acceptCriteria.add(createCriteria("4", "文档齐全", "用户手册、运维手册、API文档完整"));
        acceptCriteria.add(createCriteria("5", "培训完成", "完成用户培训并通过考核"));
        acceptCriteria.add(createCriteria("6", "数据迁移", "历史数据成功迁移并验证准确"));
        data.put("acceptCriteria", acceptCriteria);
 
        // 加载模板并生成
        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> createFeature(String id, String name, String desc) {
        Map<String, String> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("desc", desc);
        return map;
    }
 
    private static Map<String, String> createRole(String name, String desc, String permission) {
        Map<String, String> map = new HashMap<>();
        map.put("name", name);
        map.put("desc", desc);
        map.put("permission", permission);
        return map;
    }
 
    private static Map<String, String> createCriteria(String no, String item, String criteria) {
        Map<String, String> map = new HashMap<>();
        map.put("no", no);
        map.put("item", item);
        map.put("criteria", criteria);
        return map;
    }
}