添加报表已上报来源对象

This commit is contained in:
2025-10-20 11:34:05 +08:00
parent 021f6c087b
commit a7c079436b

View File

@@ -0,0 +1,88 @@
package com.zt.plat.module.qms.business.bus.controller.vo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
public class ReportedDataSource implements Serializable {
private static final long serialVersionUID = 5854800501968008943L;
/**
* 自动上报时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date autoReportedTime;
/** 已完成数据来源明细 **/
private List<DataSourceDetail> details;
/**
* 添加数据来源
* @param sourceCode 来源编码
* @param reportedOper 上报人
* @param reportedTime 上报时间
*/
public void addDataSource(String sourceCode, String reportedOper, Date reportedTime) {
if (this.details == null) {
this.details = new ArrayList<>();
this.details.add(new DataSourceDetail(sourceCode, reportedOper, reportedTime));
} else {
List<String> dataSources = this.details.stream().map(m -> m.getSourceCode()).collect(Collectors.toList());
if (dataSources.contains(sourceCode)) {
DataSourceDetail dataSourceDetail = this.details.stream().filter(f -> f.getSourceCode().equals(sourceCode)).findAny().get();
dataSourceDetail.setReportedOper(reportedOper);
dataSourceDetail.setReportedTime(reportedTime);
} else {
this.details.add(new DataSourceDetail(sourceCode, reportedOper, reportedTime));
}
}
}
/**
* 检查是否存在来源编码
* @param sourceCode 来源编码
* @return true 存在 false 不存在
*/
public boolean checkIsExist(String sourceCode) {
if (StringUtils.isBlank(sourceCode)) {
return false;
}
if (this.details == null) {
return false;
}
return this.details.stream().anyMatch(f -> sourceCode.equals(f.getSourceCode()));
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class DataSourceDetail {
/**
* 来源编码
*/
private String sourceCode;
/**
* 上报人
*/
private String reportedOper;
/**
* 上报时间
*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
private Date reportedTime;
}
}