huminmin
3 天以前 a610cbd7e6b7631254f15c832afce6e747b3581d
生产报表相关接口
已添加4个文件
548 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/controller/ProductionStatisticController.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductionStatisticDto.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/ProductionStatisticService.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionStatisticServiceImpl.java 430 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductionStatisticController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
package com.ruoyi.production.controller;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.home.dto.processDataProductionStatisticsDto;
import com.ruoyi.production.service.ProductionStatisticService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RequestMapping("productStatistics")
@RestController
@Api(tags = "生产统计")
public class ProductionStatisticController {
    @Autowired
    private ProductionStatisticService productionStatisticService;
    @ApiOperation(value = "获取生产工单数量统计数据")
    @GetMapping("/workOrderCount")
    public AjaxResult getWorkOrderCount() {
        return AjaxResult.success(productionStatisticService.getWorkOrderCount());
    }
    @ApiOperation(value = "获取质量统计数据")
    @GetMapping("/qualityStatistics")
    public AjaxResult getQualityStatistics() {
        return AjaxResult.success(productionStatisticService.getQualityStatistics());
    }
    @ApiOperation(value = "获取产量统计数据")
    @GetMapping("/productionStatistics")
    public AjaxResult getProductionStatistics() {
        return AjaxResult.success(productionStatisticService.getProductionStatistics());
    }
    @ApiOperation(value = "获取产品产出分析(饼状图)")
    @GetMapping("/productOutputCategoryPieData")
    public AjaxResult getProductOutputCategoryPieData() {
        return AjaxResult.success(productionStatisticService.getProductOutputCategoryPieData());
    }
    @ApiOperation(value = "获取工单产出不良原因统计分析")
    @GetMapping("/defectReasonAnalysis")
    public AjaxResult getDefectReasonAnalysis() {
        return AjaxResult.success(productionStatisticService.getDefectReasonAnalysis());
    }
    @ApiOperation(value = "获取工序不良率分析")
    @GetMapping("/processDefectRateAnalysis")
    public AjaxResult getProcessDefectRateAnalysis(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate) {
        return AjaxResult.success(productionStatisticService.getProcessDefectRateAnalysis(startDate, endDate));
    }
}
src/main/java/com/ruoyi/production/dto/ProductionStatisticDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
package com.ruoyi.production.dto;
import lombok.Data;
@Data
public class ProductionStatisticDto {
    private Long totalCount;
    private Long inProgressCount;
    private Long completedCount;
    private Long pendingCount;
}
src/main/java/com/ruoyi/production/service/ProductionStatisticService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,46 @@
package com.ruoyi.production.service;
import com.ruoyi.home.dto.processDataProductionStatisticsDto;
import com.ruoyi.production.dto.ProductionStatisticDto;
import java.util.List;
import java.util.Map;
public interface ProductionStatisticService {
    /**
     * èŽ·å–å·¥å•ç»Ÿè®¡æ•°æ®
     * @return åŒ…含工单总数、进行中工单、完成工单的Map
     */
    ProductionStatisticDto getWorkOrderCount();
    /**
     * èŽ·å–è´¨é‡ç»Ÿè®¡æ•°æ®
     * @return åŒ…含合格率、不良率、报废总数的Map
     */
    Map<String, Object> getQualityStatistics();
    /**
     * èŽ·å–äº§é‡ç»Ÿè®¡æ•°æ®
     * @return åŒ…含总产量总额、生产总产、生产总消耗、产品总供应公司的Map
     */
    Map<String, Object> getProductionStatistics();
    /**
     * èŽ·å–å„å·¥åºå®Œæˆåˆ†æžæ•°æ®ï¼ˆé¥¼çŠ¶å›¾ï¼‰
     * @return å·¥åºå®Œæˆåˆ†æžæ•°æ®åˆ—表
     */
    List<Map<String, Object>> getProductOutputCategoryPieData();
    /**
     * èŽ·å–å·¥å•äº§å‡ºä¸è‰¯åŽŸå› ç»Ÿè®¡åˆ†æž
     * @return ä¸è‰¯åŽŸå› ç»Ÿè®¡æ•°æ®åˆ—è¡¨
     */
    List<Map<String, Object>> getDefectReasonAnalysis();
    /**
     * èŽ·å–å·¥åºä¸è‰¯çŽ‡åˆ†æžï¼ˆæŠ˜çº¿å›¾ï¼‰
     * @return å„工序不良率数据列表
     */
    List<Map<String, Object>> getProcessDefectRateAnalysis(String startDate, String endDate);
}
src/main/java/com/ruoyi/production/service/impl/ProductionStatisticServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,430 @@
package com.ruoyi.production.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.basic.mapper.ProductMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.mapper.SupplierManageMapper;
import com.ruoyi.basic.pojo.Product;
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.basic.pojo.SupplierManage;
import com.ruoyi.home.dto.processDataProductionStatisticsDto;
import com.ruoyi.production.dto.ProductionStatisticDto;
import com.ruoyi.production.mapper.ProductProcessMapper;
import com.ruoyi.production.mapper.ProductWorkOrderMapper;
import com.ruoyi.production.mapper.ProductionProductInputMapper;
import com.ruoyi.production.mapper.ProductionProductOutputMapper;
import com.ruoyi.production.pojo.ProductProcess;
import com.ruoyi.production.pojo.ProductWorkOrder;
import com.ruoyi.production.pojo.ProductionProductInput;
import com.ruoyi.production.pojo.ProductionProductOutput;
import com.ruoyi.production.service.ProductionStatisticService;
import com.ruoyi.quality.mapper.QualityInspectMapper;
import com.ruoyi.quality.pojo.QualityInspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * ç”Ÿäº§ç»Ÿè®¡æœåŠ¡å®žçŽ°ç±»
 */
@Service
public class ProductionStatisticServiceImpl implements ProductionStatisticService {
    @Autowired
    private ProductProcessMapper productProcessMapper;
    @Autowired
    private ProductWorkOrderMapper productWorkOrderMapper;
    @Autowired
    private ProductionProductOutputMapper productionProductOutputMapper;
    @Autowired
    private ProductionProductInputMapper productionProductInputMapper;
    @Autowired
    private QualityInspectMapper qualityInspectMapper;
    @Autowired
    private SupplierManageMapper supplierManageMapper;
    @Autowired
    private ProductModelMapper productModelMapper;
    @Autowired
    private ProductMapper productMapper;
    @Override
    public ProductionStatisticDto getWorkOrderCount() {
        ProductionStatisticDto dto = new ProductionStatisticDto();
        // æŸ¥è¯¢å·¥å•总数
        Long totalCount = productWorkOrderMapper.selectCount(null);
        dto.setTotalCount(totalCount);
        // æŸ¥è¯¢è¿›è¡Œä¸­å·¥å•(完成数量小于需求数量)
        Long inProgressCount = productWorkOrderMapper.selectCount(
                new LambdaQueryWrapper<ProductWorkOrder>()
                        .apply("complete_quantity < plan_quantity and complete_quantity > 0")
        );
        dto.setInProgressCount(inProgressCount);
        // æŸ¥è¯¢å·²å®Œæˆå·¥å•(完成数量大于等于需求数量)
        Long completedCount = productWorkOrderMapper.selectCount(
                new LambdaQueryWrapper<ProductWorkOrder>()
                        .apply("complete_quantity >= plan_quantity and complete_quantity > 0")
        );
        dto.setCompletedCount(completedCount);
        // æŸ¥è¯¢å¾…完成工单(完成数量为0)
        Long pendingCount = productWorkOrderMapper.selectCount(
                new LambdaQueryWrapper<ProductWorkOrder>()
                        .eq(ProductWorkOrder::getCompleteQuantity, 0)
        );
        dto.setPendingCount(pendingCount);
        return dto;
    }
    @Override
    public Map<String, Object> getQualityStatistics() {
        Map<String, Object> result = new HashMap<>();
        // æŸ¥è¯¢æ‰€æœ‰æŠ¥å·¥è®°å½•
        List<ProductionProductOutput> outputList = productionProductOutputMapper.selectList(null);
        // è®¡ç®—报工总数、报废总数和不良总数
        BigDecimal totalOutput = BigDecimal.ZERO;
        BigDecimal totalScrap = BigDecimal.ZERO;
        BigDecimal totalDefect = BigDecimal.ZERO;
        for (ProductionProductOutput output : outputList) {
            // æŠ¥å·¥æ€»æ•°
            if (output.getQuantity() != null) {
                totalOutput = totalOutput.add(output.getQuantity());
            }
            // æŠ¥åºŸæ•°é‡
            if (output.getScrapQty() != null) {
                totalScrap = totalScrap.add(output.getScrapQty());
            }
            // ä¸è‰¯æ•°é‡ï¼ˆä»ŽQualityInspect表查询)
            List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(
                    new LambdaQueryWrapper<QualityInspect>()
                            .eq(QualityInspect::getProductMainId, output.getProductMainId())
            );
            for (QualityInspect inspect : qualityInspects) {
                if (inspect.getDefectiveQuantity() != null) {
                    totalDefect = totalDefect.add(inspect.getDefectiveQuantity());
                }
            }
        }
        // è®¡ç®—合格数量
        BigDecimal qualifiedQuantity = totalOutput.subtract(totalScrap).subtract(totalDefect);
        // è®¡ç®—合格率和不良率
        double qualifiedRate = 0.0;
        double defectRate = 0.0;
        if (totalOutput.compareTo(BigDecimal.ZERO) > 0) {
            // ä½¿ç”¨BigDecimal确保精度
            BigDecimal qualifiedRateBD = qualifiedQuantity.divide(totalOutput, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
            BigDecimal defectRateBD = totalDefect.divide(totalOutput, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
            // ä¿ç•™ä¸¤ä½å°æ•°
            qualifiedRate = qualifiedRateBD.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            defectRate = defectRateBD.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        }
        result.put("qualifiedRate", qualifiedRate); // åˆæ ¼çއ
        result.put("defectRate", defectRate); // ä¸è‰¯çއ
        result.put("scrapCount", totalScrap.intValue()); // æŠ¥åºŸæ€»æ•°
        return result;
    }
    @Override
    public Map<String, Object> getProductionStatistics() {
        Map<String, Object> result = new HashMap<>();
        // èŽ·å–å½“å‰æœˆä»½å’Œä¸Šä¸€ä¸ªæœˆä»½çš„å¼€å§‹å’Œç»“æŸæ—¶é—´
        LocalDateTime now = LocalDateTime.now();
        YearMonth currentMonth = YearMonth.from(now);
        LocalDateTime currentMonthStart = now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
        LocalDateTime currentMonthEnd =  currentMonth.atEndOfMonth().atTime(23, 59, 59);
        LocalDateTime lastMonth = now.minusMonths(1);
        LocalDateTime lastMonthStart = lastMonth.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN);
        LocalDateTime lastMonthEnd = currentMonthStart.minusDays(1).withHour(23).withMinute(59).withSecond(59);
        // è®¡ç®—生产总产出(当前月)
        List<ProductionProductOutput> currentOutputList = productionProductOutputMapper.selectList(
                new LambdaQueryWrapper<ProductionProductOutput>()
                        .ge(ProductionProductOutput::getCreateTime, currentMonthStart)
                        .le(ProductionProductOutput::getCreateTime, currentMonthEnd)
        );
        BigDecimal currentProductionOutput = BigDecimal.ZERO;
        for (ProductionProductOutput output : currentOutputList) {
            if (output.getQuantity() != null) {
                currentProductionOutput = currentProductionOutput.add(output.getQuantity());
            }
        }
        // è®¡ç®—生产总产出(上月)
        List<ProductionProductOutput> lastOutputList = productionProductOutputMapper.selectList(
                new LambdaQueryWrapper<ProductionProductOutput>()
                        .ge(ProductionProductOutput::getCreateTime, lastMonthStart)
                        .le(ProductionProductOutput::getCreateTime, lastMonthEnd)
        );
        BigDecimal lastProductionOutput = BigDecimal.ZERO;
        for (ProductionProductOutput output : lastOutputList) {
            if (output.getQuantity() != null) {
                lastProductionOutput = lastProductionOutput.add(output.getQuantity());
            }
        }
        // è®¡ç®—生产总消耗(当前月)
        List<ProductionProductInput> currentInputList = productionProductInputMapper.selectList(
                new LambdaQueryWrapper<ProductionProductInput>()
                        .ge(ProductionProductInput::getCreateTime, currentMonthStart)
                        .le(ProductionProductInput::getCreateTime, currentMonthEnd)
        );
        BigDecimal currentProductionConsumption = BigDecimal.ZERO;
        for (ProductionProductInput input : currentInputList) {
            if (input.getQuantity() != null) {
                currentProductionConsumption = currentProductionConsumption.add(input.getQuantity());
            }
        }
        // è®¡ç®—生产总消耗(上月)
        List<ProductionProductInput> lastInputList = productionProductInputMapper.selectList(
                new LambdaQueryWrapper<ProductionProductInput>()
                        .ge(ProductionProductInput::getCreateTime, lastMonthStart)
                        .le(ProductionProductInput::getCreateTime, lastMonthEnd)
        );
        BigDecimal lastProductionConsumption = BigDecimal.ZERO;
        for (ProductionProductInput input : lastInputList) {
            if (input.getQuantity() != null) {
                lastProductionConsumption = lastProductionConsumption.add(input.getQuantity());
            }
        }
        // è®¡ç®—供应商数量(当前月)
        List<SupplierManage> currentSuppliers = supplierManageMapper.selectList(
                new LambdaQueryWrapper<SupplierManage>()
                        .ge(SupplierManage::getCreateTime, currentMonthStart)
                        .le(SupplierManage::getCreateTime, currentMonthEnd)
        );
        int currentSupplierCount = currentSuppliers != null ? currentSuppliers.size() : 0;
        // è®¡ç®—供应商数量(上月)
        List<SupplierManage> lastSuppliers = supplierManageMapper.selectList(
                new LambdaQueryWrapper<SupplierManage>()
                        .ge(SupplierManage::getCreateTime, lastMonthStart)
                        .le(SupplierManage::getCreateTime, lastMonthEnd)
        );
        int lastSupplierCount = lastSuppliers != null ? lastSuppliers.size() : 0;
        // è®¡ç®—趋势
        double productionOutputMonthlyChange = 0.0;
        if (lastProductionOutput.compareTo(BigDecimal.ZERO) > 0) {
            productionOutputMonthlyChange = (currentProductionOutput.subtract(lastProductionOutput)
                    .divide(lastProductionOutput, 4, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100;
        }
        double productionConsumptionMonthlyChange = 0.0;
        if (lastProductionConsumption.compareTo(BigDecimal.ZERO) > 0) {
            productionConsumptionMonthlyChange = (currentProductionConsumption.subtract(lastProductionConsumption)
                    .divide(lastProductionConsumption, 4, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100;
        }
        double supplierCountMonthlyChange = 0.0;
        if (lastSupplierCount > 0) {
            supplierCountMonthlyChange = ((currentSupplierCount - lastSupplierCount) * 100.0) / lastSupplierCount;
        }
        result.put("productionOutput", currentProductionOutput.doubleValue()); // ç”Ÿäº§æ€»äº§
        result.put("productionConsumption", currentProductionConsumption.doubleValue()); // ç”Ÿäº§æ€»æ¶ˆè€—
        result.put("productionOutputMonthlyChange", productionOutputMonthlyChange); // ç”Ÿäº§æ€»äº§æœˆåº¦å˜åŒ–
        result.put("productionConsumptionMonthlyChange", productionConsumptionMonthlyChange); // ç”Ÿäº§æ€»æ¶ˆè€—月度变化
        result.put("supplierCount", currentSupplierCount); // äº§å“æ€»ä¾›åº”公司
        result.put("supplierCountMonthlyChange", supplierCountMonthlyChange); // ä¾›åº”商数量月度变化
        return result;
    }
    @Override
    public List<Map<String, Object>> getProductOutputCategoryPieData() {
        List<Map<String, Object>> result = new ArrayList<>();
        // æŒ‰äº§å“å¤§ç±»
        // æŸ¥è¯¢æ‰€æœ‰æŠ¥å·¥è®°å½•
        List<ProductionProductOutput> outputList = productionProductOutputMapper.selectList(null);
        // æŒ‰äº§å“åˆ†ç»„计算产出数量
        Map<Long, BigDecimal> productOutputMap = new HashMap<>();
        for (ProductionProductOutput output : outputList) {
            if (output.getProductModelId() != null && output.getQuantity() != null) {
                // æ ¹æ®productModelId查询ProductModel
                ProductModel productModel = productModelMapper.selectById(output.getProductModelId());
                if (productModel != null && productModel.getProductId() != null) {
                    // æ ¹æ®productId查询Product
                    Product product = productMapper.selectById(productModel.getProductId());
                    if (product != null) {
                        // æŒ‰äº§å“ID分组计算产出数量
                        productOutputMap.put(product.getId(),
                            productOutputMap.getOrDefault(product.getId(), BigDecimal.ZERO).add(output.getQuantity()));
                    }
                }
            }
        }
        // è½¬æ¢ä¸ºç»“果格式
        for (Map.Entry<Long, BigDecimal> entry : productOutputMap.entrySet()) {
            Product product = productMapper.selectById(entry.getKey());
            if (product != null) {
                Map<String, Object> item = new HashMap<>();
                item.put("name", product.getProductName());
                item.put("value", entry.getValue().intValue());
                result.add(item);
            }
        }
        return result;
    }
    @Override
    public List<Map<String, Object>> getDefectReasonAnalysis() {
        List<Map<String, Object>> result = new ArrayList<>();
        // æŸ¥è¯¢æ‰€æœ‰è´¨é‡æ£€éªŒè®°å½•
        List<QualityInspect> qualityInspectList = qualityInspectMapper.selectList(null);
        // æŒ‰ä¸è‰¯åŽŸå› åˆ†ç»„ç»Ÿè®¡æ•°é‡
        Map<String, Integer> reasonCountMap = new HashMap<>();
        for (QualityInspect inspect : qualityInspectList) {
            if (inspect.getDefectiveReason() != null && !inspect.getDefectiveReason().isEmpty()) {
                String reason = inspect.getDefectiveReason();
                reasonCountMap.put(reason, reasonCountMap.getOrDefault(reason, 0) + 1);
            }
        }
        // è½¬æ¢ä¸ºç»“果格式
        for (Map.Entry<String, Integer> entry : reasonCountMap.entrySet()) {
            Map<String, Object> item = new HashMap<>();
            item.put("name", entry.getKey());
            item.put("value", entry.getValue());
            result.add(item);
        }
        return result;
    }
    @Override
    public List<Map<String, Object>> getProcessDefectRateAnalysis(String startDate, String endDate) {
        List<Map<String, Object>> result = new ArrayList<>();
        // é»˜è®¤æŸ¥è¯¢è¿‘一个月数据
        if (startDate == null || endDate == null) {
            LocalDate now = LocalDate.now();
            startDate = now.minusMonths(1).toString();
            endDate = now.toString();
        }
        // è§£æžæ—¥æœŸ
        LocalDate startLocalDate = LocalDate.parse(startDate);
        LocalDate endLocalDate = LocalDate.parse(endDate);
        // æŸ¥è¯¢æ‰€æœ‰å·¥åº
        List<ProductProcess> processList = productProcessMapper.selectList(null);
        // æ”¶é›†æ‰€æœ‰æ—¥æœŸ
        Set<LocalDate> dateSet = new TreeSet<>();
        LocalDate currentDate = startLocalDate;
        while (!currentDate.isAfter(endLocalDate)) {
            dateSet.add(currentDate);
            currentDate = currentDate.plusDays(1);
        }
        // æž„建结果数据
        for (LocalDate date : dateSet) {
            Map<String, Object> item = new HashMap<>();
            item.put("date", date.toString());
            // åˆå§‹åŒ–每日总数量和不良数量
            BigDecimal dailyTotalQuantity = BigDecimal.ZERO;
            BigDecimal dailyDefectiveQuantity = BigDecimal.ZERO;
            // åˆå§‹åŒ–工序数据列表
            List<Map<String, Object>> processesList = new ArrayList<>();
            for (ProductProcess process : processList) {
                if (process.getName() != null) {
                    // æŸ¥è¯¢è¯¥å·¥åºåœ¨æŒ‡å®šæ—¥æœŸçš„质量检验记录
                    List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(
                            new LambdaQueryWrapper<QualityInspect>()
                                    .eq(QualityInspect::getProcess, process.getName())
                                    .ge(QualityInspect::getCheckTime, Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()))
                                    .lt(QualityInspect::getCheckTime, Date.from(date.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()))
                    );
                    // è®¡ç®—该工序的总检验数量和不良数量
                    BigDecimal processTotalQuantity = BigDecimal.ZERO;
                    BigDecimal processDefectiveQuantity = BigDecimal.ZERO;
                    for (QualityInspect inspect : qualityInspects) {
                        if (inspect.getQuantity() != null) {
                            processTotalQuantity = processTotalQuantity.add(inspect.getQuantity());
                            dailyTotalQuantity = dailyTotalQuantity.add(inspect.getQuantity());
                        }
                        if (inspect.getDefectiveQuantity() != null) {
                            processDefectiveQuantity = processDefectiveQuantity.add(inspect.getDefectiveQuantity());
                            dailyDefectiveQuantity = dailyDefectiveQuantity.add(inspect.getDefectiveQuantity());
                        }
                    }
                    // è®¡ç®—该工序的不良率
                    double processDefectRate = 0.0;
                    if (processTotalQuantity.compareTo(BigDecimal.ZERO) > 0) {
                        // è®¡ç®—不良率,保留两位小数
                        BigDecimal defectRateDecimal = processDefectiveQuantity.divide(processTotalQuantity, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                        processDefectRate = defectRateDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
                    }
                    // æž„建工序数据对象
                    Map<String, Object> processMap = new HashMap<>();
                    processMap.put(process.getName(), processDefectRate);
                    processesList.add(processMap);
                }
            }
            // è®¡ç®—每日平均不良率
            double dailyAverageDefectRate = 0.0;
            if (dailyTotalQuantity.compareTo(BigDecimal.ZERO) > 0) {
                // è®¡ç®—不良率,保留两位小数
                BigDecimal defectRateDecimal = dailyDefectiveQuantity.divide(dailyTotalQuantity, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                dailyAverageDefectRate = defectRateDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            }
            // æ·»åŠ å¹³å‡ä¸è‰¯çŽ‡å’Œå·¥åºæ•°æ®åˆ°ç»“æžœé¡¹
            item.put("averageDefectRate", dailyAverageDefectRate);
            item.put("processes", processesList);
            result.add(item);
        }
        return result;
    }
}