| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @RequestMapping("productOrder") |
| | |
| | | @Log(title = "生产订单", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ProductOrderDto productOrderDto) { |
| | | List<ProductOrderDto> list; |
| | | list = productOrderService.pageProductOrder(new Page<>(1, -1), productOrderDto).getRecords(); |
| | | ExcelUtil<ProductOrderDto> util = new ExcelUtil<ProductOrderDto>(ProductOrderDto.class); |
| | | List<ProductOrderDto> list = productOrderService.pageProductOrder(new Page<>(1, -1), productOrderDto).getRecords(); |
| | | |
| | | if (list != null && !list.isEmpty()) { |
| | | list.forEach(item -> { |
| | | // 判空 |
| | | if (item.getQuantity() == null || item.getCompleteQuantity() == null) { |
| | | item.setCompletionStatus(BigDecimal.ZERO); |
| | | return; |
| | | } |
| | | |
| | | // 判零 |
| | | if (item.getQuantity().compareTo(BigDecimal.ZERO) == 0) { |
| | | item.setCompletionStatus(BigDecimal.ZERO); |
| | | return; |
| | | } |
| | | BigDecimal progress = item.getCompleteQuantity() |
| | | .divide(item.getQuantity(), 4, BigDecimal.ROUND_HALF_UP) |
| | | .multiply(new BigDecimal(100)) |
| | | .setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | |
| | | item.setCompletionStatus(progress); |
| | | }); |
| | | } |
| | | |
| | | ExcelUtil<ProductOrderDto> util = new ExcelUtil<>(ProductOrderDto.class); |
| | | util.exportExcel(response, list, "生产订单数据"); |
| | | } |
| | | |