add 科室总体统计增加总计和百分比

This commit is contained in:
lijiarao
2022-10-25 15:08:16 +08:00
parent 20a3ba7456
commit fa5afbc415
5 changed files with 55 additions and 12 deletions
@@ -73,7 +73,7 @@ public class IndexController {
List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("allMoney", type,departCode);
return Result.OK(pieChartVOS);
}else if (Objects.equals(type,2)){
List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("confirmNoTaxAmount", type, departCode);
List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("no_tax_amount", type, departCode);
return Result.OK(pieChartVOS);
}else if (Objects.equals(type,3)){
List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("allMoney", type, departCode);
@@ -12,6 +12,7 @@ import com.jero.index.vo.*;
import com.jero.project.mapper.PayWorkingGroupMapper;
import com.jero.project.service.IPayWorkingGroupService;
import com.jero.statistics.entity.*;
import org.apache.ibatis.ognl.DynamicSubscript;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -23,6 +24,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import static org.apache.ibatis.ognl.DynamicSubscript.all;
/**
* @author liJiaRao
* @date 2022-09-01 16:32
@@ -189,12 +192,34 @@ public class IndexService {
private List<HistogramVO> convertDepartStatistics(List<DepartStatistics> list){
List<HistogramVO> histogramVOlist=Lists.newArrayList();
for (DepartStatistics departStatistics :list) {
String allMoney = departStatistics.getAllMoney();
String confirmAmount = departStatistics.getConfirmAmount();
HistogramVO histogramVO = new HistogramVO();
histogramVO.setName(departStatistics.getDepartName());
histogramVO.setConfirmAmount(departStatistics.getConfirmAmount());
histogramVO.setAllMoney(departStatistics.getAllMoney());
histogramVO.setConfirmAmount(confirmAmount);
histogramVO.setAllMoney(allMoney);
BigDecimal all = new BigDecimal(allMoney);
BigDecimal money = new BigDecimal(confirmAmount);
BigDecimal divide;
if (all.compareTo(BigDecimal.ZERO) == 0){
divide = BigDecimal.ZERO;
}else {
divide = money
.divide(all,3,RoundingMode.HALF_DOWN)
.multiply(new BigDecimal(100))
.setScale(1, RoundingMode.UNNECESSARY);
}
histogramVO.setValue(divide.toString());
histogramVOlist.add(histogramVO);
}
BigDecimal allConfirmAmount = list.stream().map(i -> new BigDecimal(i.getConfirmAmount())).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal allAllMoney = list.stream().map(i -> new BigDecimal(i.getAllMoney())).reduce(BigDecimal.ZERO, BigDecimal::add);
HistogramVO histogramVO = new HistogramVO();
histogramVO.setName("总计");
histogramVO.setConfirmAmount(allConfirmAmount.toString());
histogramVO.setAllMoney(allAllMoney.toString());
histogramVO.setValue("100");
histogramVOlist.add(histogramVO);
return histogramVOlist;
}
@@ -233,8 +258,10 @@ public class IndexService {
List<AmountClassDTO> amountClassDTOS;
if (Objects.equals(type,3)){
amountClassDTOS = payWorkingGroupMapper.amountClass1(year,column,departCode);
}else {
}else if (Objects.equals(type,2)){
amountClassDTOS = payWorkingGroupMapper.amountClass(year,column,departCode,type);
}else {
amountClassDTOS = payWorkingGroupMapper.amountClass2(year,column,departCode,type);
}
Map<String, BigDecimal> decimalMap = amountClassDTOS.stream().collect(Collectors.toMap(AmountClassDTO::getChargeUse, AmountClassDTO::getMoney));
//获取所有类型
@@ -17,4 +17,7 @@ public class HistogramVO {
@ApiModelProperty(value = "名字")
private String name;
@ApiModelProperty(value = "比例")
private String value;
}
@@ -232,6 +232,8 @@ public interface PayWorkingGroupMapper extends BaseMapper<PayWorkingGroup> {
List<AmountClassDTO> amountClass1(@Param("year") String year, @Param("column") String column, @Param("departCode") String departCode);
List<AmountClassDTO> amountClass2(@Param("year") String year, @Param("column") String column, @Param("departCode") String departCode, @Param("type") Integer type);
List<YearMoneyDTO> getYearMoneyDTO();
List<AllProjectStatistics> queryListConfirmAmount(@Param(value = "allProjectStatisticsSearch") AllProjectStatisticsSearch allProjectStatisticsSearch);
@@ -248,4 +250,5 @@ public interface PayWorkingGroupMapper extends BaseMapper<PayWorkingGroup> {
BigDecimal invoiceAmount(@Param("start") Integer start, @Param("end") Integer end, @Param("departCode") String departCode);
}
@@ -2400,17 +2400,25 @@
ORDER BY TMP1.paymentDate
</select>
<select id="amountClass2" resultType="com.jero.index.vo.AmountClassDTO">
SELECT chargeUse,
ifnull(SUM(${column}),0) as money
FROM v_statistical v
<where>
year like concat('%',#{year},'%')
<if test="departCode != null and departCode != ''">
and departCode = #{departCode}
</if>
</where>
GROUP BY chargeUse
</select>
<select id="amountClass" resultType="com.jero.index.vo.AmountClassDTO">
SELECT chargeUse,
ifnull(SUM(${column}),0) as money
FROM v_statistical v
ifnull(SUM(pcpr.${column}),0) as money
FROM pay_confirm_payment_record pcpr left join v_statistical v on pcpr.project_id = v.projectId
<where>
<if test="type == 1">
year like concat('%',#{year},'%')
</if>
<if test="type == 2">
and confirmDate like concat('%',#{year},'%')
</if>
and confirmDate like concat('%',#{year},'%')
<if test="departCode != null and departCode != ''">
and departCode = #{departCode}
</if>
@@ -2727,4 +2735,6 @@
</where>
) a
</select>
</mapper>