From 6bbed1ea6b36af4eb0b234bec9d6e42d56f0cd00 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期三, 30 九月 2026 16:12:49 +0800
Subject: [PATCH] feat:合同新增关联单位 开票可根据甲方或关联单位选择开票单位 收款去掉强制确认 收款只关联合同甲方或关联单位
---
platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml | 179 +++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 130 insertions(+), 49 deletions(-)
diff --git a/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml b/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
index 12793f6..39e243c 100644
--- a/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
+++ b/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
@@ -74,8 +74,8 @@
<if test="queryDTO.partyA !=null and queryDTO.partyA !=''">
and t.party_a LIKE CONCAT('%', #{queryDTO.partyA}, '%')
</if>
- <if test="queryDTO.queryArea !=null and queryDTO.queryArea !=''">
- AND t1.class_id = #{queryDTO.queryArea}
+ <if test="queryDTO.queryProvince !=null and queryDTO.queryProvince !=''">
+ AND t1.province = #{queryDTO.queryProvince}
</if>
<if test="queryDTO.queryServiceAttr !=null and queryDTO.queryServiceAttr !=''">
AND t1.export_service_attr = #{queryDTO.queryServiceAttr}
@@ -168,6 +168,33 @@
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
+ GROUP BY party_b_id, party_b
+
+ UNION ALL
+
+ SELECT
+ '鐭崇叅鏈哄叕鍙�' AS party_b_name,
+ SUM(CASE WHEN MONTH(sign_date) = 1 THEN amount ELSE 0 END) AS m01,
+ SUM(CASE WHEN MONTH(sign_date) = 2 THEN amount ELSE 0 END) AS m02,
+ SUM(CASE WHEN MONTH(sign_date) = 3 THEN amount ELSE 0 END) AS m03,
+ SUM(CASE WHEN MONTH(sign_date) = 4 THEN amount ELSE 0 END) AS m04,
+ SUM(CASE WHEN MONTH(sign_date) = 5 THEN amount ELSE 0 END) AS m05,
+ SUM(CASE WHEN MONTH(sign_date) = 6 THEN amount ELSE 0 END) AS m06,
+ SUM(CASE WHEN MONTH(sign_date) = 7 THEN amount ELSE 0 END) AS m07,
+ SUM(CASE WHEN MONTH(sign_date) = 8 THEN amount ELSE 0 END) AS m08,
+ SUM(CASE WHEN MONTH(sign_date) = 9 THEN amount ELSE 0 END) AS m09,
+ SUM(CASE WHEN MONTH(sign_date) = 10 THEN amount ELSE 0 END) AS m10,
+ SUM(CASE WHEN MONTH(sign_date) = 11 THEN amount ELSE 0 END) AS m11,
+ SUM(CASE WHEN MONTH(sign_date) = 12 THEN amount ELSE 0 END) AS m12,
+ SUM(amount) AS total_amt
+ FROM contract
+ WHERE
+ del_flag = '0'
+ AND amount IS NOT NULL
+ AND sign_date IS NOT NULL
+ AND YEAR(sign_date) = #{queryDTO.year}
+ AND party_b_id IN (2089995177814495234,2089996921978040321,2089997578009128962)
+
GROUP BY party_b_id, party_b
UNION ALL
@@ -338,6 +365,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.area_id = b.area_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -357,6 +385,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.area_id = b.area_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -376,6 +405,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.area_id = b.area_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -395,6 +425,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.area_id = b.area_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -414,6 +445,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.area_id = b.area_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -425,7 +457,8 @@
contract c
JOIN business_customer b ON c.party_a_id = b.id
WHERE
- b.area_id IS NOT NULL
+ c.del_flag='0'
+ AND b.area_id IS NOT NULL
AND YEAR ( sign_date ) = #{queryDTO.year}
GROUP BY
b.area_id
@@ -434,19 +467,18 @@
<select id="contractAmountAnalysisByIndustry"
resultType="com.by4cloud.platformx.business.vo.ContractIncomeAnalysisAreaVo">
SELECT
- b.industry_id area_id,
+ c.industry_code area_id,
SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) AS sgbze,
ROUND(
SUM( CASE WHEN c.party_b_id = #{sgbCompId} THEN c.amount ELSE 0 END ) / (
SELECT
SUM( amount )
FROM
- contract c, business_customer bc
- WHERE
- bc.id = c.party_a_id
- and c.del_flag = '0'
- and bc.del_flag = '0'
- and bc.industry_id = b.industry_id
+ contract c1
+ where
+ c1.del_flag = '0'
+ and c1.industry_code = c.industry_code
+ AND YEAR( sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -460,12 +492,11 @@
SELECT
SUM( amount )
FROM
- contract c, business_customer bc
- WHERE
- bc.id = c.party_a_id
- and c.del_flag = '0'
- and bc.del_flag = '0'
- and bc.industry_id = b.industry_id
+ contract c1
+ where
+ c1.del_flag = '0'
+ and c1.industry_code = c.industry_code
+ AND YEAR( sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -479,12 +510,11 @@
SELECT
SUM( amount )
FROM
- contract c, business_customer bc
- WHERE
- bc.id = c.party_a_id
- and c.del_flag = '0'
- and bc.del_flag = '0'
- and bc.industry_id = b.industry_id
+ contract c1
+ where
+ c1.del_flag = '0'
+ and c1.industry_code = c.industry_code
+ AND YEAR( sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -498,12 +528,11 @@
SELECT
SUM( amount )
FROM
- contract c, business_customer bc
- WHERE
- bc.id = c.party_a_id
- and c.del_flag = '0'
- and bc.del_flag = '0'
- and bc.industry_id = b.industry_id
+ contract c1
+ where
+ c1.del_flag = '0'
+ and c1.industry_code = c.industry_code
+ AND YEAR( sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -517,12 +546,11 @@
SELECT
SUM( amount )
FROM
- contract c, business_customer bc
- WHERE
- bc.id = c.party_a_id
- and c.del_flag = '0'
- and bc.del_flag = '0'
- and bc.industry_id = b.industry_id
+ contract c1
+ where
+ c1.del_flag = '0'
+ and c1.industry_code = c.industry_code
+ AND YEAR( sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -532,12 +560,12 @@
) AS tfzb
FROM
contract c
- JOIN business_customer b ON c.party_a_id = b.id
- WHERE
- b.industry_id IS NOT NULL
+ where
+ c.del_flag='0'
+ AND c.industry_code is not null
AND YEAR ( sign_date ) = #{queryDTO.year}
GROUP BY
- b.industry_id
+ c.industry_code
</select>
<select id="contractAmountAnalysisByMarket"
@@ -556,6 +584,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.class_id = b.class_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -575,6 +604,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.class_id = b.class_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -594,6 +624,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.class_id = b.class_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -613,6 +644,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.class_id = b.class_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -632,6 +664,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.class_id = b.class_id
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -643,7 +676,8 @@
contract c
JOIN business_customer b ON c.party_a_id = b.id
WHERE
- b.class_id IS NOT NULL
+ c.del_flag='0'
+ AND b.class_id IS NOT NULL
AND YEAR ( sign_date ) = #{queryDTO.year}
GROUP BY
b.class_id
@@ -666,6 +700,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.export_service_attr = b.export_service_attr
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -685,6 +720,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.export_service_attr = b.export_service_attr
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -704,6 +740,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.export_service_attr = b.export_service_attr
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -723,6 +760,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.export_service_attr = b.export_service_attr
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -742,6 +780,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.export_service_attr = b.export_service_attr
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -753,7 +792,8 @@
contract c
JOIN business_customer b ON c.party_a_id = b.id
WHERE
- b.export_service_attr IS NOT NULL
+ c.del_flag='0'
+ AND b.export_service_attr IS NOT NULL
AND YEAR ( sign_date ) = #{queryDTO.year}
GROUP BY
b.export_service_attr
@@ -773,6 +813,7 @@
WHERE
ct.del_flag = '0'
and ct.supply_attribute = c.supply_attribute
+ AND YEAR ( sign_date ) = #{queryDTO.year}
and ct.party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -790,6 +831,7 @@
WHERE
ct.del_flag = '0'
and ct.supply_attribute = c.supply_attribute
+ AND YEAR ( sign_date ) = #{queryDTO.year}
and ct.party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -807,6 +849,7 @@
WHERE
ct.del_flag = '0'
and ct.supply_attribute = c.supply_attribute
+ AND YEAR ( sign_date ) = #{queryDTO.year}
and ct.party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -824,6 +867,7 @@
WHERE
ct.del_flag = '0'
and ct.supply_attribute = c.supply_attribute
+ AND YEAR ( sign_date ) = #{queryDTO.year}
and ct.party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -841,6 +885,7 @@
WHERE
ct.del_flag = '0'
and ct.supply_attribute = c.supply_attribute
+ AND YEAR ( sign_date ) = #{queryDTO.year}
and ct.party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -896,7 +941,9 @@
DATE_FORMAT(sign_date, '%Y-%m') AS stat_month,
SUM(amount) AS total_amount
FROM contract
- WHERE YEAR(sign_date) = #{queryDTO.year}
+ WHERE
+ del_flag='0'
+ AND YEAR(sign_date) = #{queryDTO.year}
AND party_b_id = #{compId}
GROUP BY DATE_FORMAT(sign_date, '%Y-%m')
) curr ON m.stat_month = curr.stat_month
@@ -906,7 +953,8 @@
MONTH(sign_date) AS month_num,
SUM(amount) AS total_amount
FROM contract
- WHERE YEAR(sign_date) = YEAR(CURDATE())
+ WHERE del_flag='0'
+ AND YEAR(sign_date) = YEAR(CURDATE())
AND party_b_id = #{compId}
GROUP BY DATE_FORMAT(sign_date, '%Y-%m'), MONTH(sign_date)
) prev ON m.month_num = prev.month_num + 1
@@ -915,7 +963,8 @@
MONTH(sign_date) AS month_num,
SUM(amount) AS total_amount
FROM contract
- WHERE YEAR(sign_date) = YEAR(CURDATE()) - 1
+ WHERE del_flag='0'
+ AND YEAR(sign_date) = YEAR(CURDATE()) - 1
AND party_b_id = #{compId}
GROUP BY MONTH(sign_date)
) last_year ON m.month_num = last_year.month_num
@@ -938,6 +987,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.sales_model = b.sales_model
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -957,6 +1007,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.sales_model = b.sales_model
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -976,6 +1027,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.sales_model = b.sales_model
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -995,6 +1047,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.sales_model = b.sales_model
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -1014,6 +1067,7 @@
and c.del_flag = '0'
and bc.del_flag = '0'
and bc.sales_model = b.sales_model
+ AND YEAR( c.sign_date ) = #{queryDTO.year}
and party_b_id IN
<foreach collection="compIds" item="id" open="(" close=")" separator=",">
#{id}
@@ -1025,7 +1079,8 @@
contract c
JOIN business_customer b ON c.party_a_id = b.id
WHERE
- b.sales_model IS NOT NULL
+ c.del_flag='0'
+ AND b.sales_model IS NOT NULL
AND YEAR ( sign_date ) = #{queryDTO.year}
GROUP BY
b.sales_model
@@ -1040,6 +1095,7 @@
c.party_a,
c.party_b_id,
c.party_b,
+ c.party_c_id,
c.amount,
c.contract_type,
c.supply_attribute,
@@ -1063,7 +1119,11 @@
c.paid_amount,
c.contract_category,
c.exec_frequency,
+ c.next_schedule_name,
+ c.warranty_schedule_id,
c.comp_id,
+ c.center_push_flag,
+ c.last_attachment_url,
(select sum(delivered_quantity*unit_price) from contract_subject_matter csm where csm.contract_id = c.id) outAmount
FROM
contract c,
@@ -1075,6 +1135,9 @@
<if test="queryDTO.contractName !=null and queryDTO.contractName !=''">
AND contract_name LIKE CONCAT('%', #{queryDTO.contractName}, '%')
</if>
+ <if test="queryDTO.contractNo !=null and queryDTO.contractNo !=''">
+ AND contract_no LIKE CONCAT('%', #{queryDTO.contractNo}, '%')
+ </if>
<if test="queryDTO.partyA !=null and queryDTO.partyA !=''">
AND party_a LIKE CONCAT('%', #{queryDTO.partyA}, '%')
</if>
@@ -1084,8 +1147,8 @@
<if test="queryDTO.queryCompId !=null and queryDTO.queryCompId !=''">
AND c.comp_id = #{queryDTO.queryCompId}
</if>
- <if test="queryDTO.queryArea !=null and queryDTO.queryArea !=''">
- AND bc.class_id = #{queryDTO.queryArea}
+ <if test="queryDTO.queryProvince !=null and queryDTO.queryProvince !=''">
+ AND bc.province = #{queryDTO.queryProvince}
</if>
<if test="queryDTO.queryServiceAttr !=null and queryDTO.queryServiceAttr !=''">
AND bc.export_service_attr = #{queryDTO.queryServiceAttr}
@@ -1148,7 +1211,7 @@
contract c
WHERE
c.del_flag = '0'
- AND comp_id = 2056555602756063234
+ AND comp_id = 2089995177814495234
AND c.sign_date >= CURDATE()
AND c.sign_date < DATE_ADD( CURDATE(), INTERVAL 1 DAY )) smjbr,
(
@@ -1158,7 +1221,7 @@
contract c
WHERE
c.del_flag = '0'
- AND comp_id = 2056555602756063234
+ AND comp_id = 2089995177814495234
AND c.sign_date >=DATE_FORMAT( CURDATE(), '%Y-%m-01' )
AND c.sign_date < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) smjby,
(
@@ -1168,7 +1231,7 @@
contract c
WHERE
c.del_flag = '0'
- AND comp_id = 2056555602756063234
+ AND comp_id = 2089995177814495234
AND c.sign_date >=DATE_FORMAT( CURDATE(), '%Y-01-01' )
AND c.sign_date < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) smjbn,
(
@@ -1559,4 +1622,22 @@
AND c.sign_date >= DATE_FORMAT( CURDATE(), '%Y-01-01' )
AND c.sign_date < DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) hwbn
</select>
+ <select id="fourAssociation" resultType="com.by4cloud.platformx.business.vo.FourAssociationPageVo">
+ SELECT
+ c.id,
+ c.contract_no,
+ c.sign_date,
+ c.amount,
+ c.paid_amount,
+ c.billing_amout,
+ c.comp_id
+ FROM
+ contract c
+ where
+ c.del_flag = '0'
+ and c.contract_status = 2
+ order by
+ c.create_time
+
+ </select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.1