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); List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("allMoney", type,departCode);
return Result.OK(pieChartVOS); return Result.OK(pieChartVOS);
}else if (Objects.equals(type,2)){ }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); return Result.OK(pieChartVOS);
}else if (Objects.equals(type,3)){ }else if (Objects.equals(type,3)){
List<PieChartVO> pieChartVOS = indexService.totalAmountClassificationStatistics("allMoney", type, departCode); 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.mapper.PayWorkingGroupMapper;
import com.jero.project.service.IPayWorkingGroupService; import com.jero.project.service.IPayWorkingGroupService;
import com.jero.statistics.entity.*; import com.jero.statistics.entity.*;
import org.apache.ibatis.ognl.DynamicSubscript;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -23,6 +24,8 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.apache.ibatis.ognl.DynamicSubscript.all;
/** /**
* @author liJiaRao * @author liJiaRao
* @date 2022-09-01 16:32 * @date 2022-09-01 16:32
@@ -189,12 +192,34 @@ public class IndexService {
private List<HistogramVO> convertDepartStatistics(List<DepartStatistics> list){ private List<HistogramVO> convertDepartStatistics(List<DepartStatistics> list){
List<HistogramVO> histogramVOlist=Lists.newArrayList(); List<HistogramVO> histogramVOlist=Lists.newArrayList();
for (DepartStatistics departStatistics :list) { for (DepartStatistics departStatistics :list) {
String allMoney = departStatistics.getAllMoney();
String confirmAmount = departStatistics.getConfirmAmount();
HistogramVO histogramVO = new HistogramVO(); HistogramVO histogramVO = new HistogramVO();
histogramVO.setName(departStatistics.getDepartName()); histogramVO.setName(departStatistics.getDepartName());
histogramVO.setConfirmAmount(departStatistics.getConfirmAmount()); histogramVO.setConfirmAmount(confirmAmount);
histogramVO.setAllMoney(departStatistics.getAllMoney()); 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); 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; return histogramVOlist;
} }
@@ -233,8 +258,10 @@ public class IndexService {
List<AmountClassDTO> amountClassDTOS; List<AmountClassDTO> amountClassDTOS;
if (Objects.equals(type,3)){ if (Objects.equals(type,3)){
amountClassDTOS = payWorkingGroupMapper.amountClass1(year,column,departCode); amountClassDTOS = payWorkingGroupMapper.amountClass1(year,column,departCode);
}else { }else if (Objects.equals(type,2)){
amountClassDTOS = payWorkingGroupMapper.amountClass(year,column,departCode,type); 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)); Map<String, BigDecimal> decimalMap = amountClassDTOS.stream().collect(Collectors.toMap(AmountClassDTO::getChargeUse, AmountClassDTO::getMoney));
//获取所有类型 //获取所有类型
@@ -17,4 +17,7 @@ public class HistogramVO {
@ApiModelProperty(value = "名字") @ApiModelProperty(value = "名字")
private String name; 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> 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<YearMoneyDTO> getYearMoneyDTO();
List<AllProjectStatistics> queryListConfirmAmount(@Param(value = "allProjectStatisticsSearch") AllProjectStatisticsSearch allProjectStatisticsSearch); 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); BigDecimal invoiceAmount(@Param("start") Integer start, @Param("end") Integer end, @Param("departCode") String departCode);
} }
@@ -2400,17 +2400,25 @@
ORDER BY TMP1.paymentDate ORDER BY TMP1.paymentDate
</select> </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 id="amountClass" resultType="com.jero.index.vo.AmountClassDTO">
SELECT chargeUse, SELECT chargeUse,
ifnull(SUM(${column}),0) as money ifnull(SUM(pcpr.${column}),0) as money
FROM v_statistical v FROM pay_confirm_payment_record pcpr left join v_statistical v on pcpr.project_id = v.projectId
<where> <where>
<if test="type == 1"> and confirmDate like concat('%',#{year},'%')
year like concat('%',#{year},'%')
</if>
<if test="type == 2">
and confirmDate like concat('%',#{year},'%')
</if>
<if test="departCode != null and departCode != ''"> <if test="departCode != null and departCode != ''">
and departCode = #{departCode} and departCode = #{departCode}
</if> </if>
@@ -2727,4 +2735,6 @@
</where> </where>
) a ) a
</select> </select>
</mapper> </mapper>