| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | |
| | | public AjaxResult getProductInventory(SalesLedgerProduct salesLedgerProduct){ |
| | | List<SalesLedgerProduct> list = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return AjaxResult.error("该产品不存在"); |
| | | throw new RuntimeException("该产品不存在"); |
| | | } |
| | | List<ProcurementPageDto> procurementPageDtoList = new ArrayList<>(); |
| | | list.forEach(item -> { |
| | | ProcurementPageDto procurementDto = new ProcurementPageDto(); |
| | | procurementDto.setSalesLedgerProductId(String.valueOf(item.getId())); |
| | | Page<ProcurementPageDto> page = new Page<>(1, 50); |
| | | IPage<ProcurementPageDto> procurementPageDtoIPage = procurementRecordService.listPage(page, procurementDto); |
| | | IPage<ProcurementPageDto> procurementPageDtoIPage = procurementRecordService.listPage(new Page<>(1, -1), procurementDto); |
| | | procurementPageDtoList.addAll(procurementPageDtoIPage.getRecords()); |
| | | }); |
| | | if(!CollectionUtils.isEmpty(procurementPageDtoList)){ |
| | | return AjaxResult.error("该产品库存不存在"); |
| | | if(CollectionUtils.isEmpty(procurementPageDtoList)){ |
| | | throw new RuntimeException("该产品库存不存在"); |
| | | } |
| | | AtomicInteger num = new AtomicInteger(); |
| | | list.forEach(item -> { |
| | | procurementPageDtoList.forEach(procurementPageDto -> { |
| | | if(String.valueOf(item.getId().intValue()).equals(procurementPageDto.getSalesLedgerProductId())){ |
| | | if(item.getProductModelId().equals(procurementPageDto.getProductModelId())){ |
| | | if (item.getQuantity().compareTo(procurementPageDto.getInboundNum0()) <= 0) { |
| | | num.getAndIncrement(); |
| | | } |
| | |
| | | } |
| | | return AjaxResult.error("该产品库存不足"); |
| | | } |
| | | |
| | | /** |
| | | * 根据采购合同号查询详情 |
| | | */ |
| | | @GetMapping("/getSalesByCode") |
| | | public AjaxResult getSalesByCode(SalesLedgerDto salesLedgerDto) { |
| | | return AjaxResult.success(salesLedgerService.getSalesByCode(salesLedgerDto)); |
| | | } |
| | | } |