add 首页统计-》 收入分类统计

This commit is contained in:
lijiarao
2022-09-02 14:53:27 +08:00
parent 2df3a9452a
commit 842544339b
6 changed files with 81 additions and 7 deletions
@@ -1,10 +1,12 @@
package com.jero.index.contoller;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.DictPoint;
import com.jero.index.service.IndexService;
import com.jero.index.vo.HistogramVO;
import com.jero.index.vo.LineChartListVO;
import com.jero.index.vo.LineChartVO;
import com.jero.index.vo.PieChartVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -62,16 +64,20 @@ public class IndexController {
return Result.OK(histogramVOS);
}
@DictPoint
@ApiOperation(value = "总金额分类统计")
@GetMapping(value = "/totalAmountClassificationStatistics")
public Result<?> totalAmountClassificationStatistics() {
return Result.OK();
public Result<List<PieChartVO>> totalAmountClassificationStatistics() {
List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("allMoney");
return Result.OK(pieChartVOS);
}
@DictPoint
@ApiOperation(value = "收入分类统计")
@GetMapping(value = "/incomeClassificationStatistics")
public Result<?> incomeClassificationStatistics() {
return Result.OK();
public Result<List<PieChartVO>> incomeClassificationStatistics() {
List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("confirmAmount");
return Result.OK(pieChartVOS);
}
@ApiOperation(value = "前十统计")
@@ -5,14 +5,15 @@ import com.google.common.collect.Lists;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.jero.index.vo.HistogramVO;
import com.jero.index.vo.LineChartListVO;
import com.jero.index.vo.LineChartVO;
import com.jero.index.vo.*;
import com.jero.project.mapper.PayWorkingGroupMapper;
import com.jero.project.service.IPayWorkingGroupService;
import com.jero.statistics.entity.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -25,6 +26,8 @@ import java.util.stream.Collectors;
public class IndexService {
@Resource
private IPayWorkingGroupService payWorkingGroupService;
@Resource
private PayWorkingGroupMapper payWorkingGroupMapper;
public LineChartVO lineChart() {
String year = String.valueOf(DateUtil.year(new DateTime()));
@@ -204,4 +207,21 @@ public class IndexService {
}
public List<PieChartVO> totalAmountClassificationStatistics(String column) {
String year = String.valueOf(DateUtil.year(new DateTime()));
List<AmountClassDTO> amountClassDTOS = payWorkingGroupMapper.amountClass(year,column);
BigDecimal all = amountClassDTOS.stream().map(AmountClassDTO::getMoney).reduce(BigDecimal.ZERO,BigDecimal::add);
List<PieChartVO> pieChartVOS = new ArrayList<>();
for (AmountClassDTO amountClassDTO : amountClassDTOS) {
PieChartVO pieChartVO = new PieChartVO();
pieChartVO.setName(amountClassDTO.getChargeUse());
BigDecimal divide = amountClassDTO.getMoney()
.divide(all,3,RoundingMode.HALF_DOWN)
.multiply(new BigDecimal(100))
.setScale(1, RoundingMode.UNNECESSARY);
pieChartVO.setValue(String.valueOf(divide));
pieChartVOS.add(pieChartVO);
}
return pieChartVOS;
}
}
@@ -0,0 +1,15 @@
package com.jero.index.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author liJiaRao
* @date 2022-09-02 11:46
*/
@Data
public class AmountClassDTO {
private String chargeUse;
private BigDecimal money;
}
@@ -0,0 +1,19 @@
package com.jero.index.vo;
import com.jero.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @author liJiaRao
* @date 2022-09-02 11:30
*/
@Data
public class PieChartVO {
@Dict(dicCode = "payment_charge_use")
@ApiModelProperty(value = "分类")
private String name;
@ApiModelProperty(value = "")
private String value;
}
@@ -2,6 +2,7 @@ package com.jero.project.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.index.vo.AmountClassDTO;
import com.jero.project.entity.PayWorkingGroupSearch;
import com.jero.project.entity.PayWorkingGroupStatistics;
import com.jero.project.vo.PayWorkingGroupVO;
@@ -227,4 +228,6 @@ public interface PayWorkingGroupMapper extends BaseMapper<PayWorkingGroup> {
List<AllProjectStatistics> cumulativeListAllProjectMoney(@Param(value = "allProjectStatisticsSearch") AllProjectStatisticsSearch allProjectStatisticsSearch);
List<AllProjectStatistics> cumulativeListAllMoney(@Param(value = "allProjectStatisticsSearch") AllProjectStatisticsSearch allProjectStatisticsSearch);
List<AmountClassDTO> amountClass(@Param("year") String year, @Param("column") String column);
}
@@ -2310,4 +2310,15 @@
GROUP BY TMP1.paymentDate
ORDER BY TMP1.paymentDate
</select>
<select id="amountClass" resultType="com.jero.index.vo.AmountClassDTO">
SELECT chargeUse,
ifnull(SUM(${column}),0) as money
FROM v_statistical v
LEFT JOIN pay_confirm_payment_record pcpr ON (v.projectId = pcpr.project_id)
<where>
DATE_FORMAT(pcpr.payment_date, '%Y') like concat(#{year}, '%')
</where>
GROUP BY chargeUse;
</select>
</mapper>