add 未收账款统计 优化逻辑

This commit is contained in:
lijiarao
2022-10-20 16:51:32 +08:00
parent 0510deb6df
commit 8a7f5e5ee7
3 changed files with 17 additions and 37 deletions
@@ -281,15 +281,14 @@ public class IndexService {
private UncollectedPieChartVO setUncollectedPieChartVO(String name, Integer start, Integer end, String departCode){
BigDecimal bigDecimal = payWorkingGroupMapper.invoiceAmount(start, end, departCode);
BigDecimal bigDecimal1 = payWorkingGroupMapper.arrivalAmount(start, end, departCode);
UncollectedPieChartVO uncollectedPieChartVO = new UncollectedPieChartVO();
uncollectedPieChartVO.setName(name);
if (bigDecimal.compareTo(bigDecimal1) > 0){
BigDecimal subtract = bigDecimal.subtract(bigDecimal1);
uncollectedPieChartVO.setMoney(String.valueOf(subtract));
}else {
uncollectedPieChartVO.setMoney("0");
}
//if (bigDecimal.compareTo(bigDecimal1) > 0){
// BigDecimal subtract = bigDecimal.subtract(bigDecimal1);
uncollectedPieChartVO.setMoney(String.valueOf(bigDecimal));
//}else {
// uncollectedPieChartVO.setMoney("0");
//}
return uncollectedPieChartVO;
}
}
@@ -248,5 +248,4 @@ public interface PayWorkingGroupMapper extends BaseMapper<PayWorkingGroup> {
BigDecimal invoiceAmount(@Param("start") Integer start, @Param("end") Integer end, @Param("departCode") String departCode);
BigDecimal arrivalAmount(@Param("start") Integer start, @Param("end") Integer end, @Param("departCode") String departCode);
}
@@ -2701,12 +2701,13 @@
</select>
<select id="invoiceAmount" resultType="java.math.BigDecimal">
SELECT IFNULL(sum(pmbp.invoice_amount),0)
FROM pay_mail_bill pmb
left join pay_mail_bill_project pmbp on pmb.id = pmbp.bill_id
<if test="departCode != null and departCode != ''">
left join v_statistical v on v.projectId = pmbp.project_id
</if>
select
IFNULL(sum(money),0) from
(
SELECT distinct v.projectId, billMoney - ifnull(comeAllMoney,0) money
FROM v_statistical v
left join pay_mail_bill_project pmbp on v.projectId = pmbp.project_id
left join pay_mail_bill pmb on pmb.id = pmbp.bill_id
<where>
<if test="end != null">
bill_date >= DATE_SUB(CURDATE(), INTERVAL #{end} DAY)
@@ -2720,29 +2721,10 @@
<if test="departCode != null and departCode != ''">
and departCode = #{departCode}
</if>
<!-- 开票未来款 -->
AND (comeAllMoney <![CDATA[<]]> billMoney or
(comeAllMoney is null and billMoney is not null and billMoney !=0))
</where>
</select>
<select id="arrivalAmount" resultType="java.math.BigDecimal">
SELECT IFNULL(sum(amount_received),0)
FROM pay_payment_record ppr
<if test="departCode != null and departCode != ''">
left join v_statistical v on v.projectId = ppr.project_id
</if>
<where>
<if test="end != null">
payment_date >= DATE_SUB(CURDATE(), INTERVAL #{end} DAY)
</if>
<if test="start != null">
AND payment_date <![CDATA[<=]]> DATE_SUB(CURDATE(), INTERVAL #{start} DAY)
</if>
<if test="start == null">
AND payment_date <![CDATA[<=]]> CURDATE()
</if>
<if test="departCode != null and departCode != ''">
and departCode = #{departCode}
</if>
and payment_status = 'completed'
</where>
) a
</select>
</mapper>