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){ private UncollectedPieChartVO setUncollectedPieChartVO(String name, Integer start, Integer end, String departCode){
BigDecimal bigDecimal = payWorkingGroupMapper.invoiceAmount(start, end, departCode); BigDecimal bigDecimal = payWorkingGroupMapper.invoiceAmount(start, end, departCode);
BigDecimal bigDecimal1 = payWorkingGroupMapper.arrivalAmount(start, end, departCode);
UncollectedPieChartVO uncollectedPieChartVO = new UncollectedPieChartVO(); UncollectedPieChartVO uncollectedPieChartVO = new UncollectedPieChartVO();
uncollectedPieChartVO.setName(name); uncollectedPieChartVO.setName(name);
if (bigDecimal.compareTo(bigDecimal1) > 0){ //if (bigDecimal.compareTo(bigDecimal1) > 0){
BigDecimal subtract = bigDecimal.subtract(bigDecimal1); // BigDecimal subtract = bigDecimal.subtract(bigDecimal1);
uncollectedPieChartVO.setMoney(String.valueOf(subtract)); uncollectedPieChartVO.setMoney(String.valueOf(bigDecimal));
}else { //}else {
uncollectedPieChartVO.setMoney("0"); // uncollectedPieChartVO.setMoney("0");
} //}
return uncollectedPieChartVO; 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 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>
<select id="invoiceAmount" resultType="java.math.BigDecimal"> <select id="invoiceAmount" resultType="java.math.BigDecimal">
SELECT IFNULL(sum(pmbp.invoice_amount),0) select
FROM pay_mail_bill pmb IFNULL(sum(money),0) from
left join pay_mail_bill_project pmbp on pmb.id = pmbp.bill_id (
<if test="departCode != null and departCode != ''"> SELECT distinct v.projectId, billMoney - ifnull(comeAllMoney,0) money
left join v_statistical v on v.projectId = pmbp.project_id FROM v_statistical v
</if> 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> <where>
<if test="end != null"> <if test="end != null">
bill_date >= DATE_SUB(CURDATE(), INTERVAL #{end} DAY) bill_date >= DATE_SUB(CURDATE(), INTERVAL #{end} DAY)
@@ -2720,29 +2721,10 @@
<if test="departCode != null and departCode != ''"> <if test="departCode != null and departCode != ''">
and departCode = #{departCode} and departCode = #{departCode}
</if> </if>
<!-- 开票未来款 -->
AND (comeAllMoney <![CDATA[<]]> billMoney or
(comeAllMoney is null and billMoney is not null and billMoney !=0))
</where> </where>
</select> ) a
<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>
</select> </select>
</mapper> </mapper>