| | |
| | | |
| | | import com.ruoyi.basic.dto.IfsInventoryQuantitySupplierDto; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.inspect.dto.DataAnalysisDto; |
| | | import com.ruoyi.inspect.dto.MaterialPropTableDTO; |
| | | import com.ruoyi.inspect.service.DataAnalysisService; |
| | | import com.ruoyi.inspect.vo.DeviationAnalyzeVo; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 查询物料属性合格率表格 |
| | | * |
| | | * @param dataAnalysisDto |
| | | * @param dataAnalysisDto 查询参数 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "查询物料属性合格率表格") |
| | |
| | | return Result.success(dataAnalysisService.getMaterialPropTable(dataAnalysisDto)); |
| | | } |
| | | |
| | | @PostMapping("/exportSupplierExcel") |
| | | public void exportSupplierExcel(HttpServletResponse response, @RequestBody List<MaterialPropTableDTO> materialProps) { |
| | | |
| | | if (materialProps == null || materialProps.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | int index = 1; |
| | | for (MaterialPropTableDTO dto : materialProps) { |
| | | dto.setIndex(String.valueOf(index++)); |
| | | } |
| | | |
| | | int totalBatchSum = 0; |
| | | int unqualifiedBatchSum = 0; |
| | | |
| | | for (MaterialPropTableDTO dto : materialProps) { |
| | | if (dto.getTotalBatch() != null) { |
| | | totalBatchSum += dto.getTotalBatch(); |
| | | } |
| | | if (dto.getUnqualifiedBatch() != null) { |
| | | unqualifiedBatchSum += dto.getUnqualifiedBatch(); |
| | | } |
| | | } |
| | | |
| | | BigDecimal passRateSum = BigDecimal.ZERO; |
| | | if (totalBatchSum > 0) { |
| | | passRateSum = BigDecimal |
| | | .valueOf(totalBatchSum - unqualifiedBatchSum) |
| | | .multiply(BigDecimal.valueOf(100)) |
| | | .divide(BigDecimal.valueOf(totalBatchSum), 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | MaterialPropTableDTO totalRow = new MaterialPropTableDTO(); |
| | | totalRow.setIndex("合计"); |
| | | totalRow.setSupplierName(""); |
| | | totalRow.setTotalBatch(totalBatchSum); |
| | | totalRow.setUnqualifiedBatch(unqualifiedBatchSum); |
| | | totalRow.setPassRate(passRateSum); |
| | | materialProps.add(totalRow); |
| | | |
| | | ExcelUtil<MaterialPropTableDTO> excelUtil = new ExcelUtil<>(MaterialPropTableDTO.class); |
| | | excelUtil.exportExcel(response, materialProps, "合格率统计"); |
| | | } |
| | | |
| | | /** |
| | | * 查询原材料项 |
| | | * |