From cb7d99d810f2356096b67fbccd3fac556e638d83 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期四, 22 八月 2024 11:22:56 +0800
Subject: [PATCH] feat:查询条件优化
---
ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml | 48 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml
index 1bf3060..85e8d77 100644
--- a/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml
+++ b/ycl-server/src/main/resources/mapper/zgyw/CalculateReportMapper.xml
@@ -11,22 +11,26 @@
<result column="contract_id" property="contractId"/>
<result column="calculate_time" property="calculateTime"/>
<result column="deduct_money" property="deductMoney"/>
- <result column="which_year" property="whichYear"/>
- <result column="which_month" property="whichMonth"/>
+ <result column="latest_time" property="latestTime"/>
<result column="update_by" property="updateBy"/>
+ <result column="can_publish" property="canPublish"/>
+ <result column="status" property="status"/>
+ <result column="latestDeductMoney" property="latestDeductMoney"/>
</resultMap>
<select id="page" resultMap="BaseResultMap">
SELECT
- tyu.unit_name,
- tc.name,
- tcr.id,
- tcr.deduct_money,
- tcr.create_time,
- tcr.update_time,
- tcr.calculate_time,
- tcr.which_year,
- tcr.which_month
+ tcr.contract_id,
+ tyu.unit_name,
+ tc.name,
+ tcr.id,
+ tcr.status,
+ tcr.deduct_money,
+ tcr.create_time,
+ tcr.update_time,
+ tcr.calculate_time,
+ tcr.latest_time,
+ (SELECT a.deduct_money FROM (SELECT deduct_money,which_year, which_month FROM t_calculate_record WHERE contract_id = tcr.contract_id ORDER BY which_year, which_month DESC limit 1) a) as latestDeductMoney
FROM
t_calculate_report tcr
INNER JOIN t_contract tc ON tcr.contract_id = tc.id
@@ -47,6 +51,7 @@
<result column="contract_id" property="contractId"/>
<result column="calculate_time" property="calculateTime"/>
<result column="deduct_money" property="deductMoney"/>
+ <result column="status" property="status"/>
<collection property="ruleList" column="contract_id" ofType="com.ycl.platform.domain.vo.CalculateMoneyRuleVO"
select="selectRuleByContractId"/>
<collection property="recordList" column="contract_id" ofType="com.ycl.platform.domain.vo.CalculateRecordVO"
@@ -67,11 +72,16 @@
id,
create_time as createTime,
score,
- deduct_money as deductMoney
+ deduct_money as deductMoney,
+ which_year as whichYear,
+ which_month as whichMonth
FROM
t_calculate_record
WHERE
contract_id = #{contractId} AND deleted = 0
+ ORDER BY
+ create_time DESC
+
</select>
<select id="getById" resultMap="DetailResultMap">
@@ -82,11 +92,23 @@
tcr.deduct_money,
tcr.create_time,
tcr.update_time,
- tcr.calculate_time
+ tcr.calculate_time,
+ tcr.status
FROM t_calculate_report tcr
INNER JOIN t_contract tc ON tcr.contract_id = tc.id
INNER JOIN t_yw_unit tyu ON tyu.id = tc.unit_id
WHERE tcr.id = #{id}
</select>
+ <select id="exportData" resultType="com.ycl.platform.domain.excel.CalculateExport">
+ SELECT
+ a.rule_name,
+ COUNT(b.id) AS num,
+ IFNULL(-SUM(score), 0) AS score
+ FROM t_calculate_rule a
+ LEFT JOIN t_contract_score b ON b.rule_id = a.id AND auditing_status = 'PASS' AND b.deleted = 0
+ WHERE a.contract_id = #{contractId} AND a.deleted = 0
+ GROUP BY a.rule_name
+ </select>
+
</mapper>
--
Gitblit v1.8.0