付款进度代码同步

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

@@ -124,71 +124,66 @@
<select id="selectVoPagePlus" resultType="com.ruoyi.oa.domain.vo.OaProgressVo">
SELECT
op.progress_id,
op.project_id,
op.contact_phone,
op.type,
op.progress_name,
op.parent_id,
op.del_flag,
op.sort,
op.remark,
op.status,
op.amount,
op.time_remark,
sop.project_name,
sop.project_num,
sop.funds,
-- 获取 detail_status = 0 且 plan_start_date 最小的记录的 detail_name 作为 nowLevel
(
SELECT d.detail_name
SELECT op.progress_id,
op.project_id,
op.contact_phone,
op.type,
op.progress_name,
op.parent_id,
op.del_flag,
op.sort,
op.remark,
op.status,
op.amount,
op.time_remark,
sop.project_name,
sop.project_num,
sop.funds,
-- 获取 detail_status = 0 且 plan_start_date 最小的记录的 detail_name 作为 nowLevel
(SELECT d.detail_name
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
AND d.detail_status = 0
ORDER BY d.plan_start_date ASC
LIMIT 1
) AS nowLevel,
(
SELECT d.detail_id
LIMIT 1) AS nowLevel,
(select op2.contact_phone
from oa_progress op2
where op2.progress_id = op.parent_id) as parentPhone,
(SELECT d.detail_id
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
AND d.detail_status = 0
ORDER BY d.plan_start_date ASC
LIMIT 1
) AS nowLevelId,
-- 计算该记录 plan_end_date 与当前时间的天数差值作为 remainTime
(
SELECT TIMESTAMPDIFF(DAY, NOW(), d.plan_end_date)
LIMIT 1) AS nowLevelId,
-- 计算该记录 plan_end_date 与当前时间的天数差值作为 remainTime
(SELECT TIMESTAMPDIFF(DAY, NOW(), d.plan_end_date)
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
AND d.detail_status = 0
ORDER BY d.plan_start_date ASC
LIMIT 1
) AS remainTime,
LIMIT 1) AS remainTime,
(SELECT d.department
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
AND d.detail_status = 0
ORDER BY d.plan_start_date ASC
LIMIT 1) AS nowDepart,
(SELECT d.plan_end_date
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
AND d.detail_status = 0
ORDER BY d.plan_start_date ASC
LIMIT 1) AS endTime,
(
SELECT d.plan_end_date
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
AND d.detail_status = 0
ORDER BY d.plan_start_date ASC
LIMIT 1
) AS endTime,
(
SELECT d.plan_pay_date
(SELECT d.plan_pay_date
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
ORDER BY d.plan_pay_date ASC
LIMIT 1
) AS payEndTime,
-- 计算当前 progress 对应的 detail 完成比例:满足 detail_status = 1 的条数 / 总条数避免除0
(
SELECT IF(COUNT(*) = 0, 0, ROUND(SUM(CASE WHEN d.detail_status = 1 THEN 1 ELSE 0 END) / COUNT(*), 2))
LIMIT 1) AS payEndTime,
-- 计算当前 progress 对应的 detail 完成比例:满足 detail_status = 1 的条数 / 总条数避免除0
(SELECT IF(COUNT(*) = 0, 0, ROUND(SUM(CASE WHEN d.detail_status = 1 THEN 1 ELSE 0 END) / COUNT(*), 2))
FROM oa_progress_detail d
WHERE d.progress_id = op.progress_id
) AS detailCompletePercent
WHERE d.progress_id = op.progress_id) AS detailCompletePercent
FROM oa_progress op
LEFT JOIN sys_oa_project sop ON sop.project_id = op.project_id
${ew.getCustomSqlSegment}

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>