yaowanxin
10 天以前 fd7446cbdb4f852cd0d9098aa3f103fd15edbfbe
财务管理的存货核算获取数据接口,统计数据类
已添加1个文件
已修改4个文件
103 ■■■■■ 文件已修改
src/main/java/com/ruoyi/procurementrecord/controller/ProcurementRecordController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/procurementrecord/dto/InventoryInformationDto.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/procurementrecord/service/ProcurementRecordService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/procurementrecord/controller/ProcurementRecordController.java
@@ -72,7 +72,11 @@
        IPage<ProcurementPageDto> result =procurementRecordService.listPage(page, procurementDto);
        return AjaxResult.success(result);
    }
    @GetMapping("/listReport")
    @ApiOperation(value = "查询库存图表数据")
    public AjaxResult listReport() {
        return AjaxResult.success(procurementRecordService.getReportList());
    }
    @GetMapping("/listPageCopy")
    @Log(title = "采购入库-入库管理-入库查询", businessType = BusinessType.OTHER)
    public AjaxResult listPageCopy(Page page, ProcurementPageDto procurementDto) {
src/main/java/com/ruoyi/procurementrecord/dto/InventoryInformationDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package com.ruoyi.procurementrecord.dto;
import lombok.Data;
import java.math.BigDecimal;
/**
 * å­˜è´§æ ¸ç®—信息Dto-资产报表
 */
@Data
public class InventoryInformationDto {
    /**
     * æ€»åº“存数量
     */
    private Integer totalInventoryCount;
    /**
     * æ€»åº“存金额
     */
    private BigDecimal totalInventoryValue;
    /**
     * åº“存变动数量
     */
    private Integer inventoryChangeCount;
    /**
     * åº“存变动金额
     */
    private BigDecimal inventoryChangeValue;
}
src/main/java/com/ruoyi/procurementrecord/service/ProcurementRecordService.java
@@ -34,4 +34,6 @@
    void exportCopy(HttpServletResponse response);
    Map<String, Object> getReportList(Page page, ProcurementPageDto procurementDto);
    InventoryInformationDto getReportList();
}
src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -336,6 +336,69 @@
    }
    @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();
        // æ‰¹é‡æ–°å¢ž
src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml
@@ -55,10 +55,10 @@
        <where>
            1 = 1
            <if test="req.supplierName != null and req.supplierName != ''">
                and t3.supplier_name like  concat('%',#{req.supplierName},'%')
                and t3.supplier_name like concat('%',#{req.supplierName},'%')
            </if>
            <if test="req.timeStr != null and req.timeStr != ''">
                and t1.create_time like  concat('%',#{req.timeStr},'%')
                and t1.create_time like concat('%',#{req.timeStr},'%')
            </if>
        </where>
    </select>