“mitao”
2026-01-24 f72c546ff9d03608251a4186ce899b6facba6d05
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
package com.estate.expert.admin.io.processor.util;
 
import com.estate.expert.admin.domain.exam.record.Record;
import com.estate.expert.admin.domain.exam.record.error.ErrorRecord;
import com.estate.expert.admin.domain.exam.record.warning.WarningRecord;
 
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
 
/**
 * 处理器辅助类
 * 
 * 用于处理处理器中的辅助方法
 */
public class ProcessorHelper {
 
    /**
     * 获取复核状态
     * 
     * @param data 错误记录
     * @return 复核状态
     */
    public static String getReviewStateStr(ErrorRecord data) {
        if (data.getErrorReview() == null) {
            return "未复核";
        }
        return data.getErrorReview().getState().getDesc();
    }
 
    /**
     * 获取规范条款
     * 
     * @param data 错误记录
     * @return 规范条款
     */
    public static String getSpec(ErrorRecord data) {
        var indexes= data.getSpecificTermIndexes();
        if (indexes == null || indexes.isEmpty()) {
            return "";
        }
 
        var problem = data.getProblem();
        var sb = new StringBuilder();
        for (var index : indexes) {
            var spec = problem.getSpecificTerms().get(index);
            if(spec!= null)
                sb.append(spec).append(";");
        }
        return sb.toString();
    }
 
    /**
     * 获取规范条款
     * 
     * @param data 警告记录
     * @return 规范条款
     */
    public static String getSpec(WarningRecord data) {
        var problem = data.getProblem();
        if(problem.getSpecificTerms() == null)
            return "";
        var sb = new StringBuilder();
        for(var st : problem.getSpecificTerms()) {
            if(st!= null)
                sb.append(st).append(";");
        }
        return sb.toString();
    }
 
    /**
     * 格式化日期时间
     * 
     * @param dateTime 日期时间
     * @return 格式化后的日期时间
     */
    public static String formatDateTime(LocalDateTime dateTime) {
        if (dateTime == null) {
            return "";
        }
        return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }
 
    /**
     * 获取层级名称
     * 
     * @param data 记录
     * @param index 层级索引
     * @return 层级名称
     */
    public static String getHierarchyName(Record data, int index) {
        if(data.getHierarchyNames() != null && index < data.getHierarchyNames().size())
            return data.getHierarchyNames().get(index);
        return "";
    }
 
}