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 "";
|
}
|
|
}
|