|
|
|
|
@ -7,6 +7,7 @@ import org.dromara.qms.domain.dto.InspectionCountDto;
|
|
|
|
|
import org.dromara.qms.domain.vo.report.DailyTestReportVo;
|
|
|
|
|
import org.dromara.qms.domain.vo.report.DefectAnalysisReportVo;
|
|
|
|
|
import org.dromara.qms.domain.vo.report.WeeklyTestReportVo;
|
|
|
|
|
import org.dromara.qms.domain.vo.report.IqcEfficiencyReportVo;
|
|
|
|
|
import org.dromara.qms.mapper.ReportMapper;
|
|
|
|
|
import org.dromara.qms.service.IReportService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -25,59 +26,89 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
|
|
|
|
|
private final ReportMapper reportMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取周检测报告
|
|
|
|
|
*
|
|
|
|
|
* @param startTime 开始时间
|
|
|
|
|
* @param endTime 结束时间
|
|
|
|
|
* @return 周检测报告数据
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public WeeklyTestReportVo getWeeklyTestReport(String startTime, String endTime) {
|
|
|
|
|
// 查询每日检测数量和不合格数量
|
|
|
|
|
List<InspectionCountDto> dailyInspectionCount = reportMapper.selectInspectionCounts(startTime, endTime);
|
|
|
|
|
// 查询每日缺陷数据
|
|
|
|
|
List<DefectDataDto> dailyDefectData = reportMapper.selectDefectData(startTime, endTime);
|
|
|
|
|
|
|
|
|
|
// 构建每日报告映射表,以日期为键存储每日报告数据
|
|
|
|
|
Map<String, DailyTestReportVo> dailyReportMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 处理检测数量数据,将数据库查询结果转换为每日报告对象
|
|
|
|
|
for (InspectionCountDto inspectionCount : dailyInspectionCount) {
|
|
|
|
|
String date = inspectionCount.getTestDate();
|
|
|
|
|
// 如果该日期的报告对象不存在则创建新的报告对象
|
|
|
|
|
DailyTestReportVo dailyReport = dailyReportMap.computeIfAbsent(date, k -> new DailyTestReportVo());
|
|
|
|
|
dailyReport.setDate(date);
|
|
|
|
|
// 设置星期几的中文名称
|
|
|
|
|
dailyReport.setDayOfWeek(getDayOfWeek(date));
|
|
|
|
|
// 设置检测数量,如果为空则设为0
|
|
|
|
|
dailyReport.setInspectionQty(inspectionCount.getInspectionQty() != null ? inspectionCount.getInspectionQty() : BigDecimal.ZERO);
|
|
|
|
|
// 设置不合格数量,如果为空则设为0
|
|
|
|
|
dailyReport.setDefectQty(inspectionCount.getUnqualifiedQty() != null ? inspectionCount.getUnqualifiedQty() : BigDecimal.ZERO);
|
|
|
|
|
// 初始化缺陷类型统计Map
|
|
|
|
|
dailyReport.setDefectTypeSummary(new HashMap<>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理缺陷类型数据,将缺陷类型统计信息填充到对应的日期报告中
|
|
|
|
|
for (DefectDataDto defectData : dailyDefectData) {
|
|
|
|
|
String date = defectData.getTestDate();
|
|
|
|
|
DailyTestReportVo dailyReport = dailyReportMap.get(date);
|
|
|
|
|
// 只有当该日期的报告存在且缺陷类型不为空时才进行统计
|
|
|
|
|
if (dailyReport != null && defectData.getDefectType() != null) {
|
|
|
|
|
dailyReport.getDefectTypeSummary().put(defectData.getDefectType(), defectData.getDefectCount());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 转换为列表并计算缺陷率
|
|
|
|
|
List<DailyTestReportVo> dailyReports = new ArrayList<>(dailyReportMap.values());
|
|
|
|
|
// 遍历每日报告,计算每日的缺陷率
|
|
|
|
|
for (DailyTestReportVo report : dailyReports) {
|
|
|
|
|
// 计算每日缺陷率:不合格数量/检测数量*100%,保留4位小数进行计算,最后格式化为百分比字符串
|
|
|
|
|
if (report.getInspectionQty().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
// 缺陷率 = 不合格数量 / 检测数量 * 100%
|
|
|
|
|
BigDecimal defectRate = report.getDefectQty().divide(report.getInspectionQty(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
report.setDefectRate(String.format("%.2f%%", defectRate));
|
|
|
|
|
} else {
|
|
|
|
|
// 如果检测数量为0,则缺陷率为0%
|
|
|
|
|
report.setDefectRate("0.00%");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 按日期排序,确保报告按时间顺序展示
|
|
|
|
|
dailyReports.sort(Comparator.comparing(DailyTestReportVo::getDate));
|
|
|
|
|
|
|
|
|
|
// 构建周报对象,用于汇总一周的数据
|
|
|
|
|
WeeklyTestReportVo weeklyReport = new WeeklyTestReportVo();
|
|
|
|
|
weeklyReport.setDailyReports(dailyReports);
|
|
|
|
|
|
|
|
|
|
// 计算总检测数量和总缺陷数量,用于计算整体缺陷率
|
|
|
|
|
BigDecimal totalInspectionQty = dailyReports.stream().map(DailyTestReportVo::getInspectionQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
BigDecimal totalDefectQty = dailyReports.stream().map(DailyTestReportVo::getDefectQty).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
weeklyReport.setTotalInspectionQty(totalInspectionQty);
|
|
|
|
|
weeklyReport.setTotalDefectQty(totalDefectQty);
|
|
|
|
|
|
|
|
|
|
// 计算总缺陷率,方法与每日缺陷率计算相同
|
|
|
|
|
if (totalInspectionQty.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
// 总缺陷率 = 总不合格数量 / 总检测数量 * 100%
|
|
|
|
|
BigDecimal totalDefectRate = totalDefectQty.divide(totalInspectionQty, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
weeklyReport.setTotalDefectRate(String.format("%.2f%%", totalDefectRate));
|
|
|
|
|
} else {
|
|
|
|
|
// 如果总检测数量为0,则总缺陷率为0%
|
|
|
|
|
weeklyReport.setTotalDefectRate("0.00%");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 统计各类缺陷类型的总数,用于缺陷类型分布分析
|
|
|
|
|
Map<String, Integer> totalDefectTypeSummary = dailyReports.stream()
|
|
|
|
|
.flatMap(r -> r.getDefectTypeSummary().entrySet().stream())
|
|
|
|
|
.collect(Collectors.groupingBy(Map.Entry::getKey, Collectors.summingInt(Map.Entry::getValue)));
|
|
|
|
|
@ -87,55 +118,80 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
return weeklyReport;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取缺陷分析报告
|
|
|
|
|
*
|
|
|
|
|
* @param startTime 开始时间
|
|
|
|
|
* @param endTime 结束时间
|
|
|
|
|
* @return 缺陷分析报告数据
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public DefectAnalysisReportVo getDefectAnalysisReport(String startTime, String endTime) {
|
|
|
|
|
// 获取所有检测类型
|
|
|
|
|
// 获取所有检测类型,用于构建报告的行标题
|
|
|
|
|
List<String> inspectionTypes = reportMapper.selectInspectionTypes();
|
|
|
|
|
|
|
|
|
|
// 获取不良品分析数据
|
|
|
|
|
|
|
|
|
|
// 获取不良品分析数据,包含检验数量、不合格数、不合格记录数等指标
|
|
|
|
|
List<DefectAnalysisDto> analysisData = reportMapper.selectDefectAnalysisData(startTime, endTime);
|
|
|
|
|
|
|
|
|
|
// 生成日期范围
|
|
|
|
|
|
|
|
|
|
// 生成日期范围,用于构建报告的列标题
|
|
|
|
|
List<String> dateRange = generateDateRange(startTime, endTime);
|
|
|
|
|
|
|
|
|
|
// 构建表格数据
|
|
|
|
|
|
|
|
|
|
// 构建表格数据,将原始数据转换为前端展示所需的格式
|
|
|
|
|
List<Map<String, Object>> tableData = buildTableData(analysisData, inspectionTypes, dateRange);
|
|
|
|
|
|
|
|
|
|
// 构建日期列信息
|
|
|
|
|
|
|
|
|
|
// 构建日期列信息,包含日期和星期几的显示信息
|
|
|
|
|
List<DefectAnalysisReportVo.DateColumnInfo> dateColumns = buildDateColumns(dateRange);
|
|
|
|
|
|
|
|
|
|
// 构建图表数据
|
|
|
|
|
|
|
|
|
|
// 构建图表数据,用于前端图表展示
|
|
|
|
|
DefectAnalysisReportVo.ChartData chartData = buildChartData(analysisData, dateRange);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建最终的报告对象
|
|
|
|
|
DefectAnalysisReportVo reportVo = new DefectAnalysisReportVo();
|
|
|
|
|
reportVo.setTableData(tableData);
|
|
|
|
|
reportVo.setDateColumns(dateColumns);
|
|
|
|
|
reportVo.setInspectionTypes(inspectionTypes);
|
|
|
|
|
reportVo.setChartData(chartData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reportVo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成日期范围列表
|
|
|
|
|
*
|
|
|
|
|
* @param startTime 开始时间
|
|
|
|
|
* @param endTime 结束时间
|
|
|
|
|
* @return 日期范围列表
|
|
|
|
|
*/
|
|
|
|
|
private List<String> generateDateRange(String startTime, String endTime) {
|
|
|
|
|
List<String> dateRange = new ArrayList<>();
|
|
|
|
|
LocalDate start = LocalDate.parse(startTime);
|
|
|
|
|
LocalDate end = LocalDate.parse(endTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalDate current = start;
|
|
|
|
|
// 遍历日期范围内的每一天,将日期添加到列表中
|
|
|
|
|
while (!current.isAfter(end)) {
|
|
|
|
|
dateRange.add(current.toString());
|
|
|
|
|
current = current.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return dateRange;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> buildTableData(List<DefectAnalysisDto> analysisData,
|
|
|
|
|
List<String> inspectionTypes,
|
|
|
|
|
/**
|
|
|
|
|
* 构建表格数据
|
|
|
|
|
*
|
|
|
|
|
* @param analysisData 分析数据
|
|
|
|
|
* @param inspectionTypes 检测类型列表
|
|
|
|
|
* @param dateRange 日期范围
|
|
|
|
|
* @return 表格数据
|
|
|
|
|
*/
|
|
|
|
|
private List<Map<String, Object>> buildTableData(List<DefectAnalysisDto> analysisData,
|
|
|
|
|
List<String> inspectionTypes,
|
|
|
|
|
List<String> dateRange) {
|
|
|
|
|
List<Map<String, Object>> tableData = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 按指标类型分组数据
|
|
|
|
|
|
|
|
|
|
// 按指标类型分组数据:metric -> bizDate -> typeName -> value
|
|
|
|
|
// 将原始数据按指标、日期、检测类型进行多级分组,便于后续数据查询和计算
|
|
|
|
|
Map<String, Map<String, Map<String, BigDecimal>>> groupedData = analysisData.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(
|
|
|
|
|
DefectAnalysisDto::getMetric,
|
|
|
|
|
@ -149,63 +205,79 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
)
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
// 构建检验数量行
|
|
|
|
|
// 构建检验数量行,统计每日各类检测的总检验数量
|
|
|
|
|
Map<String, Object> inspectionRow = new HashMap<>();
|
|
|
|
|
inspectionRow.put("metric", "检验数量 (单位: 个)");
|
|
|
|
|
BigDecimal totalInspection = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 统计每日检验总数,遍历每一天计算该日所有检测类型的检验数量总和
|
|
|
|
|
for (String date : dateRange) {
|
|
|
|
|
BigDecimal dayTotal = BigDecimal.ZERO;
|
|
|
|
|
// 获取该日期的检验数量数据
|
|
|
|
|
Map<String, Map<String, BigDecimal>> dateData = groupedData.get("检验数量(单位:个)");
|
|
|
|
|
if (dateData != null && dateData.containsKey(date)) {
|
|
|
|
|
// 汇总当日各类检测的检验数量
|
|
|
|
|
for (String type : inspectionTypes) {
|
|
|
|
|
BigDecimal value = dateData.get(date).getOrDefault(type, BigDecimal.ZERO);
|
|
|
|
|
dayTotal = dayTotal.add(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 将当日总计存入行数据中
|
|
|
|
|
inspectionRow.put(date, dayTotal);
|
|
|
|
|
// 累加到总检验数量
|
|
|
|
|
totalInspection = totalInspection.add(dayTotal);
|
|
|
|
|
}
|
|
|
|
|
// 添加总计列
|
|
|
|
|
inspectionRow.put("total", totalInspection);
|
|
|
|
|
tableData.add(inspectionRow);
|
|
|
|
|
|
|
|
|
|
// 构建不良数量行
|
|
|
|
|
// 构建不良数量行,统计每日各类检测的总不良数量
|
|
|
|
|
Map<String, Object> defectRow = new HashMap<>();
|
|
|
|
|
defectRow.put("metric", "不良数量 (单位: 个)");
|
|
|
|
|
BigDecimal totalDefect = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 统计每日不良总数,遍历每一天计算该日所有检测类型的不合格数量总和
|
|
|
|
|
for (String date : dateRange) {
|
|
|
|
|
BigDecimal dayTotal = BigDecimal.ZERO;
|
|
|
|
|
// 获取该日期的不合格数数据
|
|
|
|
|
Map<String, Map<String, BigDecimal>> dateData = groupedData.get("不合格数(单位:个)");
|
|
|
|
|
if (dateData != null && dateData.containsKey(date)) {
|
|
|
|
|
// 汇总当日各类检测的不合格数量
|
|
|
|
|
for (String type : inspectionTypes) {
|
|
|
|
|
BigDecimal value = dateData.get(date).getOrDefault(type, BigDecimal.ZERO);
|
|
|
|
|
dayTotal = dayTotal.add(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 将当日总计存入行数据中
|
|
|
|
|
defectRow.put(date, dayTotal);
|
|
|
|
|
// 累加到总不良数量
|
|
|
|
|
totalDefect = totalDefect.add(dayTotal);
|
|
|
|
|
}
|
|
|
|
|
// 添加总计列
|
|
|
|
|
defectRow.put("total", totalDefect);
|
|
|
|
|
tableData.add(defectRow);
|
|
|
|
|
|
|
|
|
|
// 构建不良率行
|
|
|
|
|
// 构建不良率行,根据检验数量和不良数量计算每日不良率
|
|
|
|
|
Map<String, Object> rateRow = new HashMap<>();
|
|
|
|
|
rateRow.put("metric", "不良率 (单位: %)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算每日不良率,遍历每一天计算该日的不良率
|
|
|
|
|
for (String date : dateRange) {
|
|
|
|
|
// 获取该日期的检验数量和不良数量
|
|
|
|
|
BigDecimal inspectionQty = (BigDecimal) inspectionRow.get(date);
|
|
|
|
|
BigDecimal defectQty = (BigDecimal) defectRow.get(date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 不良率 = 不良数量 / 检验数量 * 100%,保留两位小数
|
|
|
|
|
if (inspectionQty.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
BigDecimal rate = defectQty.divide(inspectionQty, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
rateRow.put(date, rate.setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
} else {
|
|
|
|
|
// 如果检验数量为0,则不良率为0
|
|
|
|
|
rateRow.put(date, BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算总不良率
|
|
|
|
|
|
|
|
|
|
// 计算总不良率,基于总检验数量和总不良数量计算
|
|
|
|
|
if (totalInspection.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
BigDecimal totalRate = totalDefect.divide(totalInspection, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
rateRow.put("total", totalRate.setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
@ -214,21 +286,27 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
}
|
|
|
|
|
tableData.add(rateRow);
|
|
|
|
|
|
|
|
|
|
// 构建各检测类型行
|
|
|
|
|
// 构建各检测类型行,分别展示每种检测类型的检验数量
|
|
|
|
|
for (String type : inspectionTypes) {
|
|
|
|
|
Map<String, Object> typeRow = new HashMap<>();
|
|
|
|
|
typeRow.put("metric", type + " (单位: 个)");
|
|
|
|
|
BigDecimal typeTotal = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 统计每种检测类型的每日检验数量
|
|
|
|
|
for (String date : dateRange) {
|
|
|
|
|
BigDecimal value = BigDecimal.ZERO;
|
|
|
|
|
// 获取该日期的检验数量数据
|
|
|
|
|
Map<String, Map<String, BigDecimal>> dateData = groupedData.get("检验数量(单位:个)");
|
|
|
|
|
if (dateData != null && dateData.containsKey(date)) {
|
|
|
|
|
// 获取该检测类型在该日期的检验数量
|
|
|
|
|
value = dateData.get(date).getOrDefault(type, BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
// 将数据存入行数据中
|
|
|
|
|
typeRow.put(date, value);
|
|
|
|
|
// 累加到该检测类型的总计
|
|
|
|
|
typeTotal = typeTotal.add(value);
|
|
|
|
|
}
|
|
|
|
|
// 添加该检测类型的总计列
|
|
|
|
|
typeRow.put("total", typeTotal);
|
|
|
|
|
tableData.add(typeRow);
|
|
|
|
|
}
|
|
|
|
|
@ -236,44 +314,68 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
return tableData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建日期列信息
|
|
|
|
|
*
|
|
|
|
|
* @param dateRange 日期范围
|
|
|
|
|
* @return 日期列信息列表
|
|
|
|
|
*/
|
|
|
|
|
private List<DefectAnalysisReportVo.DateColumnInfo> buildDateColumns(List<String> dateRange) {
|
|
|
|
|
return dateRange.stream().map(date -> {
|
|
|
|
|
DefectAnalysisReportVo.DateColumnInfo columnInfo = new DefectAnalysisReportVo.DateColumnInfo();
|
|
|
|
|
// 格式化日期显示:M月d日,例如"9月15日"
|
|
|
|
|
columnInfo.setDate(LocalDate.parse(date).format(DateTimeFormatter.ofPattern("M月d日")));
|
|
|
|
|
// 设置星期几的中文名称
|
|
|
|
|
columnInfo.setDayOfWeek(getDayOfWeek(date));
|
|
|
|
|
// 设置属性名,用于前端绑定
|
|
|
|
|
columnInfo.setProp(date);
|
|
|
|
|
return columnInfo;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建图表数据
|
|
|
|
|
*
|
|
|
|
|
* @param analysisData 分析数据
|
|
|
|
|
* @param dateRange 日期范围
|
|
|
|
|
* @return 图表数据
|
|
|
|
|
*/
|
|
|
|
|
private DefectAnalysisReportVo.ChartData buildChartData(List<DefectAnalysisDto> analysisData, List<String> dateRange) {
|
|
|
|
|
DefectAnalysisReportVo.ChartData chartData = new DefectAnalysisReportVo.ChartData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 格式化日期显示用于图表,转换为"月日"格式
|
|
|
|
|
List<String> dates = dateRange.stream()
|
|
|
|
|
.map(date -> LocalDate.parse(date).format(DateTimeFormatter.ofPattern("M月d日")))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化图表数据序列
|
|
|
|
|
List<BigDecimal> inspectionData = new ArrayList<>();
|
|
|
|
|
List<BigDecimal> defectData = new ArrayList<>();
|
|
|
|
|
List<BigDecimal> defectRateData = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 按日期和指标分组数据
|
|
|
|
|
|
|
|
|
|
// 按日期和指标分组数据,重新组织数据结构便于图表展示
|
|
|
|
|
Map<String, Map<String, BigDecimal>> dailyData = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 重新组织数据结构:日期 -> 指标 -> 值,将原始数据转换为按日期分组的结构
|
|
|
|
|
for (DefectAnalysisDto data : analysisData) {
|
|
|
|
|
dailyData.computeIfAbsent(data.getBizDate(), k -> new HashMap<>())
|
|
|
|
|
.merge(data.getMetric(), data.getValue(), BigDecimal::add);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建图表数据序列,遍历每一天生成对应的图表数据
|
|
|
|
|
for (String date : dateRange) {
|
|
|
|
|
// 获取该日期的数据
|
|
|
|
|
Map<String, BigDecimal> dayData = dailyData.getOrDefault(date, new HashMap<>());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取检验数量和不良数量
|
|
|
|
|
BigDecimal inspection = dayData.getOrDefault("检验数量(单位:个)", BigDecimal.ZERO);
|
|
|
|
|
BigDecimal defect = dayData.getOrDefault("不合格数(单位:个)", BigDecimal.ZERO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加到图表数据序列中
|
|
|
|
|
inspectionData.add(inspection);
|
|
|
|
|
defectData.add(defect);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算当日不良率,方法与前面相同
|
|
|
|
|
if (inspection.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
BigDecimal rate = defect.divide(inspection, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
defectRateData.add(rate.setScale(2, RoundingMode.HALF_UP));
|
|
|
|
|
@ -281,17 +383,29 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
defectRateData.add(BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置图表数据
|
|
|
|
|
chartData.setDates(dates);
|
|
|
|
|
chartData.setInspectionData(inspectionData);
|
|
|
|
|
chartData.setDefectData(defectData);
|
|
|
|
|
chartData.setDefectRateData(defectRateData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return chartData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取指定日期的星期几
|
|
|
|
|
*
|
|
|
|
|
* @param dateStr 日期字符串 (格式: yyyy-MM-dd)
|
|
|
|
|
* @return 星期几的中文名称
|
|
|
|
|
*/
|
|
|
|
|
private String getDayOfWeek(String dateStr) {
|
|
|
|
|
LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
|
return date.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINESE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<IqcEfficiencyReportVo> getIncomingInspectionEfficiency(String startTime, String endTime) {
|
|
|
|
|
return reportMapper.selectIqcEfficiencyReport(startTime, endTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|