付款进度代码同步

This commit is contained in:
2025-06-07 15:15:55 +08:00
parent d5660ee8aa
commit ce5e217c0c
21 changed files with 515 additions and 99 deletions

View File

@@ -585,6 +585,189 @@
from sys_oa_project sop
where sop.project_id = #{projectId}
</select>
<!-- 本月合同总额 -->
<select id="selectTotalFunds" resultType="java.math.BigDecimal">
SELECT IFNULL(SUM(funds),0)
FROM sys_oa_project
<where>
AND begin_time BETWEEN #{start} AND #{end}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
</select>
<!-- 历史(月度)平均合同总额 -->
<select id="selectPrevAvgTotalFunds" resultType="java.math.BigDecimal">
SELECT IFNULL(AVG(monthly_sum),0)
FROM (
SELECT SUM(funds) AS monthly_sum
FROM sys_oa_project
<where>
AND begin_time &lt; #{start}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
GROUP BY YEAR(begin_time), MONTH(begin_time)
) t
</select>
<!-- 本月合同数量 -->
<select id="selectContractCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM sys_oa_project
<where>
AND begin_time BETWEEN #{start} AND #{end}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
</select>
<!-- 历史(月度)平均合同数量 -->
<select id="selectPrevAvgContractCount" resultType="java.math.BigDecimal">
SELECT IFNULL(AVG(monthly_cnt),0)
FROM (
SELECT COUNT(*) AS monthly_cnt
FROM sys_oa_project
<where>
AND begin_time &lt; #{start}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
GROUP BY YEAR(begin_time), MONTH(begin_time)
) t
</select>
<!-- 本月临期项目数(仅未完成) -->
<select id="selectExpiringCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM sys_oa_project
<where>
AND project_status = '0'
AND finish_time BETWEEN #{start} AND #{end}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
</select>
<!-- 历史(月度)平均临期项目数 -->
<select id="selectPrevAvgExpiringCount" resultType="java.math.BigDecimal">
SELECT IFNULL(AVG(monthly_expiring),0)
FROM (
SELECT COUNT(*) AS monthly_expiring
FROM sys_oa_project
<where>
AND project_status = '0'
AND finish_time &lt; #{start}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
GROUP BY YEAR(finish_time), MONTH(finish_time)
) t
</select>
<select id="selectContractAmountTrend" resultType="com.ruoyi.oa.domain.vo.TrendPointVo">
SELECT
CONCAT(t.mth, '月') AS month,
t.value
FROM (
SELECT
YEAR(begin_time) AS yr,
MONTH(begin_time) AS mth,
IFNULL(SUM(funds),0) AS value
FROM sys_oa_project
<where>
AND begin_time BETWEEN #{start} AND #{end}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
GROUP BY
YEAR(begin_time),
MONTH(begin_time)
) AS t
ORDER BY
t.yr,
t.mth
</select>
<select id="selectProjectStatusDistribution" resultType="com.ruoyi.oa.domain.vo.StatusCountVo">
SELECT status, COUNT(*) AS count FROM (
SELECT
CASE
WHEN NOW() > finish_time THEN '已逾期'
WHEN finish_time BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 7 DAY) THEN '即将到期'
WHEN project_status = '0' THEN '进行中'
ELSE '正常'
END AS status
FROM sys_oa_project
<where>
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
) t
GROUP BY status
</select>
<select id="selectMonthlyContractComparison" resultType="com.ruoyi.oa.domain.vo.TrendPointVo">
SELECT
CONCAT(t.mth, '月') AS month,
t.value
FROM (
SELECT
YEAR(begin_time) AS yr,
MONTH(begin_time) AS mth,
COUNT(*) AS value
FROM sys_oa_project
<where>
AND begin_time BETWEEN #{start} AND #{end}
<if test="tradeType !=null and tradeType !=''">
and trade_type = #{tradeType}
</if>
</where>
GROUP BY
YEAR(begin_time),
MONTH(begin_time)
) AS t
ORDER BY
t.yr,
t.mth
</select>
<select id="selectExpiringForeignProjects" resultType="com.ruoyi.oa.domain.vo.SysOaProjectVo">
SELECT
p.project_id AS projectId,
p.project_name AS projectName,
p.funds AS funds,
p.finish_time AS finishTime,
CASE
WHEN NOW() > p.finish_time THEN '已逾期'
WHEN p.finish_time BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL #{expireDays} DAY) THEN '即将到期'
ELSE '进行中'
END AS status,
TIMESTAMPDIFF(
DAY,
NOW(),
p.finish_time
) AS remainTime
FROM sys_oa_project p
<where>
AND TIMESTAMPDIFF(DAY, NOW(), p.finish_time) &lt; #{expireDays}
AND p.project_status = '0'
<if test="tradeType !=null and tradeType !=''">
and p.trade_type = #{tradeType}
</if>
</where>
ORDER BY
TIMESTAMPDIFF(DAY, NOW(), p.finish_time) ASC
</select>
</mapper>