| | |
| | | } |
| | | |
| | | @Override |
| | | public InventoryInformationDto getReportList() { |
| | | InventoryInformationDto inventoryInformationDto = new InventoryInformationDto(); |
| | | IPage<ProcurementPageDto> procurementPageDtoIPage = this.listPage(new Page<>(1, -1), new ProcurementPageDto()); |
| | | if(CollectionUtils.isEmpty(procurementPageDtoIPage.getRecords())){ |
| | | return inventoryInformationDto; |
| | | } |
| | | // è®¡ç®æ»åºåæ°é |
| | | inventoryInformationDto.setTotalInventoryCount(procurementPageDtoIPage.getRecords().stream() |
| | | .map(ProcurementPageDto::getInboundNum0) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | .intValue()); |
| | | // è®¡ç®æ»åºåéé¢-ProcurementPageDtoéæ¯ä¸ªå¯¹è±¡çinboundNum0å¼åtaxInclusiveUnitPriceçä¹ç§¯ï¼ä¹åç¸å å¾å°æ»åºåéé¢ |
| | | BigDecimal totalInventoryValue = procurementPageDtoIPage.getRecords().stream() |
| | | // è¿æ»¤ç©ºå¯¹è±¡ï¼é¿å
NPE |
| | | .filter(Objects::nonNull) |
| | | // å¤çæ¯ä¸ªå¯¹è±¡ç空å¼ï¼null转为0 |
| | | .map(dto -> { |
| | | // å
¥åºæ°éï¼null â 0 |
| | | BigDecimal inboundNum0 = Optional.ofNullable(dto.getInboundNum0()).orElse(BigDecimal.ZERO); |
| | | // å«ç¨åä»·ï¼null â 0 |
| | | BigDecimal taxInclusiveUnitPrice = Optional.ofNullable(dto.getTaxInclusiveUnitPrice()).orElse(BigDecimal.ZERO); |
| | | // 计ç®å个对象çåºåéé¢ï¼æ°é à å«ç¨åä»· |
| | | return inboundNum0.multiply(taxInclusiveUnitPrice); |
| | | }) |
| | | // ææå个é颿±åï¼åå§å¼ä¸º0 |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 设置æ»åºåéé¢ |
| | | inventoryInformationDto.setTotalInventoryValue(totalInventoryValue); |
| | | // 计ç®åºåå卿°é-ProcurementPageDtoéæ¯ä¸ªå¯¹è±¡çinboundNumå¼åinboundNum0å¼çå·®å¼ï¼ä¹åç¸å å¾å°åºåå卿°é |
| | | inventoryInformationDto.setInventoryChangeCount(procurementPageDtoIPage.getRecords().stream() |
| | | // è¿æ»¤ç©ºå¯¹è±¡ï¼é¿å
NPE |
| | | .filter(Objects::nonNull) |
| | | // å¤çæ¯ä¸ªå¯¹è±¡ç空å¼ï¼null转为0 |
| | | .map(dto -> { |
| | | // å
¥åºæ°éï¼null â 0 |
| | | BigDecimal inboundNum = Optional.ofNullable(dto.getInboundNum()).orElse(BigDecimal.ZERO); |
| | | // å¾
åºåºæ°éï¼null â 0 |
| | | BigDecimal inboundNum0 = Optional.ofNullable(dto.getInboundNum0()).orElse(BigDecimal.ZERO); |
| | | // 计ç®å个对象çåºåå卿°éï¼æ°é - å¾
åºåºæ°é |
| | | return inboundNum.subtract(inboundNum0); |
| | | }) |
| | | // ææå个å卿°éæ±åï¼åå§å¼ä¸º0 |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add) |
| | | .intValue()); |
| | | // 计ç®åºååå¨éé¢ProcurementPageDtoéæ¯ä¸ªå¯¹è±¡çtaxInclusiveTotalPriceå¼çå |
| | | BigDecimal inventoryChangeValue = procurementPageDtoIPage.getRecords().stream() |
| | | // è¿æ»¤ç©ºå¯¹è±¡ï¼é¿å
NPE |
| | | .filter(Objects::nonNull) |
| | | // å¤çæ¯ä¸ªå¯¹è±¡ç空å¼ï¼null转为0 |
| | | .map(dto -> { |
| | | // å«ç¨æ»ä»·ï¼null â 0 |
| | | BigDecimal taxInclusiveTotalPrice = Optional.ofNullable(dto.getTaxInclusiveTotalPrice()).orElse(BigDecimal.ZERO); |
| | | // 计ç®å个对象çå
¥åºåºåéé¢ï¼å«ç¨æ»ä»· |
| | | return taxInclusiveTotalPrice; |
| | | }) |
| | | // ææå个åå¨é颿±åï¼åå§å¼ä¸º0 |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 设置åºååå¨éé¢ |
| | | inventoryInformationDto.setInventoryChangeValue(inventoryChangeValue.subtract(totalInventoryValue)); |
| | | return inventoryInformationDto; |
| | | } |
| | | |
| | | @Override |
| | | public int add(ProcurementAddDto procurementDto) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | // æ¹éæ°å¢ |