From 96118de3ac74f5468cf5d4ac73d6ea3bec1da010 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期五, 20 十一月 2026 14:36:25 +0800
Subject: [PATCH] feat:新增销售指标 产品板块 重点工作 专项业务 产品收入和合同统计修改功能 feat:承兑新增承兑编号字段 feat:客商主数据更新名称 专项业务去年同月字段 机动车销售发票地址字段及判断 feat:银行流水更新客户id feat:机动车销售发票新增税务及代码字段 feat:流水更新按钮参数 feat:检索新增标的物运维按钮

---
 platformx-business-finance-biz/src/main/resources/mapper/PaymentReceiveMapper.xml | 1555 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 1,505 insertions(+), 50 deletions(-)

diff --git a/platformx-business-finance-biz/src/main/resources/mapper/PaymentReceiveMapper.xml b/platformx-business-finance-biz/src/main/resources/mapper/PaymentReceiveMapper.xml
index 8778005..812f3cd 100644
--- a/platformx-business-finance-biz/src/main/resources/mapper/PaymentReceiveMapper.xml
+++ b/platformx-business-finance-biz/src/main/resources/mapper/PaymentReceiveMapper.xml
@@ -3,78 +3,1533 @@
 
 <mapper namespace="com.by4cloud.platformx.business.mapper.PaymentReceiveMapper">
 
-  <resultMap id="paymentReceiveMap" type="com.by4cloud.platformx.business.entity.PaymentReceive">
-        <id property="id" column="id"/>
-        <result property="compId" column="comp_id"/>
-        <result property="receiveAmount" column="receive_amount"/>
-        <result property="receiveDate" column="receive_date"/>
-  </resultMap>
+	<resultMap id="paymentReceiveMap" type="com.by4cloud.platformx.business.entity.PaymentReceive">
+		<id property="id" column="id"/>
+		<result property="compId" column="comp_id"/>
+		<result property="receiveAmount" column="receive_amount"/>
+		<result property="receiveDate" column="receive_date"/>
+	</resultMap>
 	<select id="genReceivePayment" resultType="java.math.BigDecimal">
 		SELECT
-			sum(c.billing_amout - c.paid_amount)
+		sum(c.billing_amout - c.paid_amount)
 		FROM
-			contract c
+		contract c
 		WHERE
-		    c.del_flag = '0'
-			AND c.billing_amout >= paid_amount
+		c.del_flag = '0'
+		AND c.billing_amout >= paid_amount
 		<if test="compId!=null">
 			AND c.comp_id = #{compId}
 		</if>
 	</select>
 	<select id="genReceivePaymentSmj" resultType="java.math.BigDecimal">
-		SELECT
-			sum(c.billing_amout - c.paid_amount)
-		FROM
-			contract c
-		WHERE
-			c.del_flag = '0'
+		SELECT sum(c.billing_amout - c.paid_amount)
+		FROM contract c
+		WHERE c.del_flag = '0'
 		  AND c.billing_amout >= paid_amount
-		  AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+		  AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or
+			   comp_id = 2101966257365045249)
 	</select>
 	<select id="zbjtReceiveScale" resultType="com.by4cloud.platformx.business.vo.ZbjtIndicatorTrendVo">
 		WITH RECURSIVE month_series AS (
-			SELECT
-				DATE_FORMAT( CURDATE(), '%Y-%m-01' ) AS month_start UNION ALL
-			SELECT
-				DATE_SUB( month_start, INTERVAL 1 MONTH )
-			FROM
-				month_series
-			WHERE
-				month_start &gt; DATE_SUB( DATE_FORMAT( CURDATE(), '%Y-%m-01' ), INTERVAL 11 MONTH )
-		) SELECT
-			  DATE_FORMAT( ms.month_start, '%m' ) AS `yearMon`,
-			  COALESCE ( SUM( ps.receive_amount ), 0 ) AS `je`
+		SELECT
+		DATE_FORMAT( CURDATE(), '%Y-%m-01' ) AS month_start UNION ALL
+		SELECT
+		DATE_SUB( month_start, INTERVAL 1 MONTH )
 		FROM
-			month_series ms
-				LEFT JOIN payment_receive ps ON DATE_FORMAT( ps.receive_date, '%Y-%m' ) = DATE_FORMAT( ms.month_start, '%Y-%m' )
+		month_series
+		WHERE
+		month_start &gt; DATE_SUB( DATE_FORMAT( CURDATE(), '%Y-%m-01' ), INTERVAL 11 MONTH )
+		) SELECT
+		DATE_FORMAT( ms.month_start, '%m' ) AS `yearMon`,
+		COALESCE ( SUM( ps.receive_amount ), 0 ) AS `je`
+		FROM
+		month_series ms
+		LEFT JOIN payment_receive ps ON DATE_FORMAT( ps.receive_date, '%Y-%m' ) = DATE_FORMAT( ms.month_start, '%Y-%m' )
 		<if test="compId !=null">
 			AND ps.comp_id = #{compId}
 		</if>
 		GROUP BY
-			ms.month_start
+		ms.month_start
 		ORDER BY
-			ms.month_start ASC;
+		ms.month_start ASC;
 	</select>
 	<select id="zbjtReceiveScaleSMJ" resultType="com.by4cloud.platformx.business.vo.ZbjtIndicatorTrendVo">
 		WITH RECURSIVE month_series AS (
-			SELECT
-				DATE_FORMAT( CURDATE(), '%Y-%m-01' ) AS month_start UNION ALL
-			SELECT
-				DATE_SUB( month_start, INTERVAL 1 MONTH )
-			FROM
-				month_series
-			WHERE
-				month_start &gt; DATE_SUB( DATE_FORMAT( CURDATE(), '%Y-%m-01' ), INTERVAL 11 MONTH )
-		) SELECT
-			  DATE_FORMAT( ms.month_start, '%m' ) AS `yearMon`,
-			  COALESCE ( SUM( ps.receive_amount ), 0 ) AS `je`
+			SELECT DATE_FORMAT(CURDATE(), '%Y-%m-01') AS month_start
+			UNION ALL
+			SELECT DATE_SUB(month_start, INTERVAL 1 MONTH )
+			FROM month_series
+			WHERE month_start &gt; DATE_SUB(DATE_FORMAT(CURDATE(), '%Y-%m-01'), INTERVAL 11 MONTH )
+		)
+		SELECT DATE_FORMAT(ms.month_start, '%m')   AS `yearMon`,
+			   COALESCE(SUM(ps.receive_amount), 0) AS `je`
+		FROM month_series ms
+				 LEFT JOIN payment_receive ps
+						   ON DATE_FORMAT(ps.receive_date, '%Y-%m') = DATE_FORMAT(ms.month_start, '%Y-%m')
+							   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or
+									comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+		GROUP BY ms.month_start
+		ORDER BY ms.month_start ASC;
+	</select>
+	<select id="yszkwcqk" resultType="com.by4cloud.platformx.business.vo.YszkwcqkVo">
+		SELECT *
+		FROM (
+				 SELECT '鐭崇叅鏈�'                                       dw,
+						'搴旀敹'                                        lb,
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2089995177814495234
+						   and receive_date &gt;= #{monstart}
+						   and receive_date &lt;= #{monend})        ysdy,
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2089995177814495234
+						   and receive_date &gt;= #{yearstart}
+						   and receive_date &lt;= #{yearend})       ysqc,
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2089995177814495234
+						   and receive_date &gt;= #{monstartLastMon}
+						   and receive_date &lt;= #{monendLastMon}) yssy
+				 UNION ALL
+				 SELECT '鐭崇叅鏈�' dw,
+						'璧婇攢'  lb,
+						(SELECT IFNULL(sum(credit_amount), 0)
+						 FROM payment_credit_sale
+						 WHERE comp_id = 2089995177814495234
+						   and credit_date &gt;= #{monstart}
+						   and credit_date &lt;= #{monend}),
+						(SELECT IFNULL(sum(credit_amount), 0)
+						 FROM payment_credit_sale
+						 WHERE comp_id = 2089995177814495234
+						   and credit_date &gt;= #{yearstart}
+						   and credit_date &lt;= #{yearend}),
+						(SELECT IFNULL(sum(credit_amount), 0)
+						 FROM payment_credit_sale
+						 WHERE comp_id = 2089995177814495234
+						   and credit_date &gt;= #{monstartLastMon}
+						   and credit_date &lt;= #{monendLastMon})
+				 UNION ALL
+				 SELECT '鐭崇叅鏈�'                                                                                       dw,
+						'灏忚'                                                                                        lb,
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2089995177814495234
+						   and receive_date &gt;= #{monstart}
+						   and receive_date &lt;= #{monend}) + (SELECT IFNULL(sum(credit_amount), 0)
+																FROM payment_credit_sale
+																WHERE comp_id = 2089995177814495234
+																  and credit_date &gt;= #{monstart}
+																  and credit_date &lt;= #{monend})               AS smjysdy,
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2089995177814495234
+						   and receive_date &gt;= #{yearstart}
+						   and receive_date &lt;= #{yearend}) + (SELECT IFNULL(sum(credit_amount), 0)
+																 FROM payment_credit_sale
+																 WHERE comp_id = 2089995177814495234
+																   and credit_date &gt;= #{yearstart}
+																   and credit_date &lt;= #{yearend})             AS smjysqc,
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2089995177814495234
+						   and receive_date &gt;= #{monstartLastMon}
+						   and receive_date &lt;= #{monendLastMon}) + (SELECT IFNULL(sum(credit_amount), 0)
+																	   FROM payment_credit_sale
+																	   WHERE comp_id = 2089995177814495234
+																		 and credit_date &gt;= #{monstartLastMon}
+																		 and credit_date &lt;= #{monendLastMon}) AS smjyssy
+				 UNION ALL
+				 SELECT '鐭冲伐娉�' dw,
+						'搴旀敹'  lb,
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2056556196124250113
+						   and receive_date &gt;= #{monstart}
+						   and receive_date &lt;= #{monend}),
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2056556196124250113
+						   and receive_date &gt;= #{yearstart}
+						   and receive_date &lt;= #{yearend}),
+						(SELECT IFNULL(sum(receive_amount), 0)
+						 FROM payment_receive
+						 WHERE comp_id = 2056556196124250113
+						   and receive_date &gt;= #{monstartLastMon}
+						   and receive_date &lt;= #{monendLastMon})
+				 UNION ALL
+				 SELECT '鐭冲伐娉�' dw,
+						'璧婇攢'  lb,
+						(SELECT IFNULL(sum(credit_amount), 0)
+						 FROM payment_credit_sale
+						 WHERE comp_id = 2056556196124250113
+						   and credit_date &gt;= #{monstart}
+						   and credit_date &lt;= #{monend}),
+						(SELECT IFNULL(sum(credit_amount), 0)
+						 FROM payment_credit_sale
+						 WHERE comp_id = 2056556196124250113
+						   and credit_date &gt;= #{yearstart}
+						   and credit_date 	&lt;= #{yearend}),
+			 (SELECT IFNULL(sum(credit_amount), 0)
+			  FROM payment_credit_sale
+			  WHERE comp_id = 2056556196124250113
+				and credit_date  &gt;=  #{monstartLastMon}
+				and	credit_date	&lt;= #{monendLastMon}	)
+		UNION
+		ALL
+		SELECT '鐭冲伐娉�' dw,
+			   '灏忚'  lb,
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556196124250113
+				  and receive_date &gt;= #{monstart}
+				  and receive_date &lt;= #{monend}) + (SELECT IFNULL(sum(credit_amount), 0)
+													   FROM payment_credit_sale
+													   WHERE comp_id = 2056556196124250113
+														 and credit_date &gt;= #{monstart}
+														 and credit_date &lt;= #{monend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556196124250113
+				  and receive_date &gt;= #{yearstart}
+				  and receive_date &lt;= #{yearend}) + (SELECT IFNULL(sum(credit_amount), 0)
+														FROM payment_credit_sale
+														WHERE comp_id = 2056556196124250113
+														  and credit_date &gt;= #{yearstart}
+														  and credit_date &lt;= #{yearend}),
+			   (
+				   SELECT IFNULL(sum(receive_amount), 0)
+				   FROM payment_receive
+				   WHERE comp_id = 2056556196124250113
+					 and receive_date &gt;= #{monstartLastMon}
+					 and receive_date &lt;= #{monendLastMon}) + (
+				   SELECT IFNULL(sum(credit_amount), 0)
+				   FROM payment_credit_sale
+				   WHERE comp_id = 2056556196124250113
+					 and credit_date &gt;= #{monstartLastMon}
+					 and credit_date &lt;= #{monendLastMon})
+		UNION ALL
+		SELECT '閭㈠彴鍘�' dw,
+			   '搴旀敹'  lb,
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556317461270529
+				  and receive_date &gt;= #{monstart}
+				  and receive_date &lt;= #{monend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556317461270529
+				  and receive_date &gt;= #{yearstart}
+				  and receive_date &lt;= #{yearend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556317461270529
+				  and receive_date &gt;= #{monstartLastMon}
+				  and receive_date &lt;= #{monendLastMon})
+		UNION ALL
+		SELECT '閭㈠彴鍘�' dw,
+			   '璧婇攢'  lb,
+			   (SELECT IFNULL(sum(credit_amount), 0)
+				FROM payment_credit_sale
+				WHERE comp_id = 2056556317461270529
+				  and credit_date &gt;= #{monstart}
+				  and credit_date &lt;= #{monend}),
+			   (SELECT IFNULL(sum(credit_amount), 0)
+				FROM payment_credit_sale
+				WHERE comp_id = 2056556317461270529
+				  and credit_date &gt;= #{yearstart}
+				  and credit_date &lt;= #{yearend}),
+			(
+		SELECT IFNULL(sum (credit_amount), 0)
+		FROM payment_credit_sale
+		WHERE comp_id = 2056556317461270529
+		  and credit_date &gt;= #{monstartLastMon}
+		  and credit_date &lt;= #{monendLastMon})
+		UNION ALL
+		SELECT '閭㈠彴鍘�' dw,
+			   '灏忚'  lb,
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556317461270529
+				  and receive_date &gt;= #{monstart}
+				  and receive_date &lt;= #{monend}) + (SELECT IFNULL(sum(credit_amount), 0)
+													   FROM payment_credit_sale
+													   WHERE comp_id = 2056556317461270529
+														 and credit_date &gt;= #{monstart}
+														 and credit_date &lt;= #{monend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556317461270529
+				  and receive_date &gt;= #{yearstart}
+				  and receive_date &lt;= #{yearend}) + (SELECT IFNULL(sum(credit_amount), 0)
+														FROM payment_credit_sale
+														WHERE comp_id = 2056556317461270529
+														  and credit_date &gt;= #{yearstart}
+														  and credit_date &lt;= #{yearend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556317461270529
+				  and receive_date &gt;= #{monstartLastMon}
+				  and receive_date &lt;= #{monendLastMon}) + (SELECT IFNULL(sum(credit_amount), 0)
+															  FROM payment_credit_sale
+															  WHERE comp_id = 2056556317461270529
+																and credit_date &gt;= #{monstartLastMon}
+																and credit_date &lt;= #{monendLastMon})
+		UNION ALL
+		SELECT '閫氭柟鍘�' dw,
+			   '搴旀敹'  lb,
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556421857497090
+				  and receive_date &gt;= #{monstart}
+				  and receive_date &lt;= #{monend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556421857497090
+				  and receive_date &gt;= #{yearstart}
+				  and receive_date &lt;= #{yearend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556421857497090
+				  and receive_date &gt;= #{monstartLastMon}
+				  and receive_date &lt;= #{monendLastMon})
+		UNION ALL
+		SELECT '閫氭柟鍘�' dw,
+			   '璧婇攢'  lb,
+			   (SELECT IFNULL(sum(credit_amount), 0)
+				FROM payment_credit_sale
+				WHERE comp_id = 2056556421857497090
+				  and credit_date &gt;= #{monstart}
+				  and credit_date &lt;= #{monend}),
+			   (SELECT IFNULL(sum(credit_amount), 0)
+				FROM payment_credit_sale
+				WHERE comp_id = 2056556421857497090
+				  and credit_date &gt;= #{yearstart}
+				  and credit_date &lt;= #{yearend}),
+			(
+		SELECT IFNULL(sum (credit_amount), 0)
+		FROM payment_credit_sale
+		WHERE comp_id = 2056556421857497090
+		  and credit_date &gt;= #{monstartLastMon}
+		  and credit_date &lt;= #{monendLastMon})
+		UNION ALL
+		SELECT '閫氭柟鍘�' dw,
+			   '灏忚'  lb,
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556421857497090
+				  and receive_date &gt;= #{monstart}
+				  and receive_date &lt;= #{monend}) + (SELECT IFNULL(sum(credit_amount), 0)
+													   FROM payment_credit_sale
+													   WHERE comp_id = 2056556421857497090
+														 and credit_date &gt;= #{monstart}
+														 and credit_date &lt;= #{monend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556421857497090
+				  and receive_date &gt;= #{yearstart}
+				  and receive_date &lt;= #{yearend}) + (SELECT IFNULL(sum(credit_amount), 0)
+														FROM payment_credit_sale
+														WHERE comp_id = 2056556421857497090
+														  and credit_date &gt;= #{yearstart}
+														  and credit_date &lt;= #{yearend}),
+			   (SELECT IFNULL(sum(receive_amount), 0)
+				FROM payment_receive
+				WHERE comp_id = 2056556421857497090
+				  and receive_date &gt;= #{monstartLastMon}
+				  and receive_date &lt;= #{monendLastMon}) + (SELECT IFNULL(sum(credit_amount), 0)
+															  FROM payment_credit_sale
+															  WHERE comp_id = 2056556421857497090
+																and credit_date &gt;= #{monstartLastMon}
+																and credit_date &lt;= #{monendLastMon}) ) a
+	</select>
+    <select id="zbjtjznbyszk" resultType="com.by4cloud.platformx.business.vo.JznbyszkVo">
+		SELECT
+		zgs,
+		wfyssx,
+		( wfyssx - sx ) dfgz,
+		sx,
+		hxhtze,
+		lynjhht,
+		lywjhht
 		FROM
-			month_series ms
-				LEFT JOIN payment_receive ps ON DATE_FORMAT( ps.receive_date, '%Y-%m' ) = DATE_FORMAT( ms.month_start, '%Y-%m' )
-				AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
-		GROUP BY
-			ms.month_start
-		ORDER BY
-			ms.month_start ASC;
+		(
+		SELECT
+		'鍐�涓偂浠�' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM
+		contract_out_bound cob
+		WHERE
+		del_flag = '0'
+		AND EXISTS (
+		SELECT
+		*
+		FROM
+		contract c
+		WHERE
+		c.del_flag = '0'
+		AND c.id = cob.contract_id
+		AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓偂浠�' AND c.party_a = branch ))
+		<if test="compId!=null">
+				AND comp_id = #{compId}
+			</if>
+		    )) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM
+		contract_out_bound cob
+		WHERE
+		del_flag = '0'
+		AND EXISTS (
+		SELECT
+		*
+		FROM
+		contract c
+		WHERE
+		c.del_flag = '0'
+		AND c.id = cob.contract_id
+		AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓偂浠�' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 )  FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		 ) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 )  FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 )  FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'宄板嘲闆嗗洟' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM
+		contract_out_bound cob
+		WHERE
+		del_flag = '0'
+		AND EXISTS (
+		SELECT
+		*
+		FROM
+		contract c
+		WHERE
+		c.del_flag = '0'
+		AND c.id = cob.contract_id
+		AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '宄板嘲闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM
+		contract_out_bound cob
+		WHERE
+		del_flag = '0'
+		AND EXISTS (
+		SELECT
+		*
+		FROM
+		contract c
+		WHERE
+		c.del_flag = '0'
+		AND c.id = cob.contract_id
+		AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '宄板嘲闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'閭㈢熆闆嗗洟' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM
+		contract_out_bound cob
+		WHERE
+		del_flag = '0'
+		AND EXISTS (
+		SELECT
+		*
+		FROM
+		contract c
+		WHERE
+		c.del_flag = '0'
+		AND c.id = cob.contract_id
+		AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭㈢熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM
+		contract_out_bound cob
+		WHERE
+		del_flag = '0'
+		AND EXISTS (
+		SELECT
+		*
+		FROM
+		contract c
+		WHERE
+		c.del_flag = '0'
+		AND c.id = cob.contract_id
+		AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭㈢熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'閭熆闆嗗洟' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+		WHERE
+		del_flag = '0'
+		AND EXISTS (
+		SELECT
+		*
+		FROM
+		contract c
+		WHERE
+		c.del_flag = '0'
+		AND c.id = cob.contract_id
+		AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'灞辫タ鍐�涓�' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '灞辫タ鍐�涓�' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '灞辫タ鍐�涓�' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'浜曠熆闆嗗洟' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '浜曠熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '浜曠熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'寮犵熆闆嗗洟' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '寮犵熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '寮犵熆闆嗗洟' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'鍐�涓兘婧�' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓兘婧�' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓兘婧�' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'璁惧绉熻祦' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '璁惧绉熻祦' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '璁惧绉熻祦' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		union all
+		SELECT
+		'渚涘簲閾�' zgs,
+		((
+		SELECT
+		IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '渚涘簲閾�' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '渚涘簲閾�' AND c.party_a = branch ))
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+		AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+		<if test="compId!=null">
+			AND comp_id = #{compId}
+		</if>
+		) lywjhht
+		) a
+	</select>
+	<select id="zbjtjznbyszkSMJ" resultType="com.by4cloud.platformx.business.vo.JznbyszkVo">
+		SELECT
+		zgs,
+		wfyssx,
+		( wfyssx - sx ) dfgz,
+		sx,
+		hxhtze,
+		lynjhht,
+		lywjhht
+		FROM
+		(
+		SELECT
+		'鍐�涓偂浠�' zgs,
+		((
+		SELECT
+				IFNULL(sum( billing_amout - paid_amount ), 0 )
+		FROM
+		contract
+		WHERE
+		del_flag = '0'
+		AND billing_amout >= paid_amount
+		  AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+	    AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		)+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓偂浠�' AND c.party_a = branch ))
+		AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+		)) wfyssx,
+		( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓偂浠�' AND c.party_a = branch ))
+		AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+		AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+														   AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		    ) hxhtze,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+		AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+														   AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		    ) lynjhht,
+		( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+	   	AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+														   AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓偂浠�' and party_a = branch )
+		    ) lywjhht
+		    union all
+		SELECT
+			'宄板嘲闆嗗洟' zgs,
+			((
+				 SELECT
+					 IFNULL(sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '宄板嘲闆嗗洟' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '宄板嘲闆嗗洟' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '宄板嘲闆嗗洟' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'閭㈢熆闆嗗洟' zgs,
+			((
+				 SELECT
+						 IFNULL( sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭㈢熆闆嗗洟' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭㈢熆闆嗗洟' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL( sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+																AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL( sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+																AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL( sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+																AND EXISTS (SELECT * from jz_group_branch where `group` = '閭㈢熆闆嗗洟' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'閭熆闆嗗洟' zgs,
+			((
+				 SELECT
+					 IFNULL( sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭熆闆嗗洟' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '閭熆闆嗗洟' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL( sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+																AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL( sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+																AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL( sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+																AND EXISTS (SELECT * from jz_group_branch where `group` = '閭熆闆嗗洟' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'灞辫タ鍐�涓�' zgs,
+			((
+				 SELECT
+						 IFNULL(sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '灞辫タ鍐�涓�' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '灞辫タ鍐�涓�' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '灞辫タ鍐�涓�' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'浜曠熆闆嗗洟' zgs,
+			((
+				 SELECT
+					 IFNULL(sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '浜曠熆闆嗗洟' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '浜曠熆闆嗗洟' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '浜曠熆闆嗗洟' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'寮犵熆闆嗗洟' zgs,
+			((
+				 SELECT
+						 IFNULL(sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '寮犵熆闆嗗洟' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '寮犵熆闆嗗洟' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '寮犵熆闆嗗洟' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'鍐�涓兘婧�' zgs,
+			((
+				 SELECT
+					 IFNULL(sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓兘婧�' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '鍐�涓兘婧�' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '鍐�涓兘婧�' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'璁惧绉熻祦' zgs,
+			((
+				 SELECT
+						 IFNULL(sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '璁惧绉熻祦' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '璁惧绉熻祦' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '璁惧绉熻祦' and party_a = branch )
+			    ) lywjhht
+		union all
+		SELECT
+			'渚涘簲閾�' zgs,
+			((
+				 SELECT
+						 IFNULL(sum( billing_amout - paid_amount ), 0 )
+				 FROM
+					 contract
+				 WHERE
+					 del_flag = '0'
+				   AND billing_amout >= paid_amount
+				   AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+			 )+ ( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '渚涘簲閾�' AND c.party_a = branch ))
+																																AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+			 )) wfyssx,
+			( SELECT IFNULL( sum( unit_price *( out_bound_num - advance_num - invoice_num )), 0 ) FROM contract_out_bound cob
+			WHERE
+				del_flag = '0'
+				AND EXISTS (
+				SELECT
+					*
+				FROM
+					contract c
+				WHERE
+					c.del_flag = '0'
+					AND c.id = cob.contract_id
+				AND EXISTS ( SELECT * FROM jz_group_branch WHERE `group` = '渚涘簲閾�' AND c.party_a = branch ))
+																															AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)) sx,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{monend}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+			    ) hxhtze,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &lt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+			    ) lynjhht,
+			( SELECT IFNULL(sum( amount ), 0 ) FROM contract WHERE del_flag = '0' AND contract_status = 2 AND expiration_date &gt;= #{mon2after}
+												   AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
+															   AND EXISTS (SELECT * from jz_group_branch where `group` = '渚涘簲閾�' and party_a = branch )
+			) lywjhht
+		) a
 	</select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1