Просмотр исходного кода

widNumber字段导致导出数据有重复,根据list的sql调整导出sql

huangguoce 1 месяц назад
Родитель
Сommit
9b09fb2eba
1 измененных файлов с 41 добавлено и 10 удалено
  1. 41 10
      src/main/resources/mappings/modules/workinvoice/WorkInvoiceDao.xml

+ 41 - 10
src/main/resources/mappings/modules/workinvoice/WorkInvoiceDao.xml

@@ -1163,10 +1163,34 @@
 		a.new_drawer_id as "newDrawerId",
 		a.new_drawer as "newDrawer",
 		a.is_sz_cloud as "isSzCloud",
-		a.actual_drawer_id as "actualDrawerId"
-		,wid.number as "widNumber"
-		,wid.total_money as "widTotalMoney",
-		wid.total_money as "widTotalMoneyD",
+		a.actual_drawer_id as "actualDrawerId",
+		(
+		SELECT
+			wid.number
+		FROM
+			work_invoice_detail wid
+		WHERE
+			a.id = wid.invoice_id
+		LIMIT 1
+		) AS widNumber,
+		(
+		SELECT
+			wid.total_money
+		FROM
+			work_invoice_detail wid
+		WHERE
+			a.id = wid.invoice_id
+		LIMIT 1
+		) AS widTotalMoney,
+		(
+		SELECT
+		wid.total_money
+		FROM
+		work_invoice_detail wid
+		WHERE
+		a.id = wid.invoice_id
+		LIMIT 1
+		) AS widTotalMoneyD,
 		(select
 		CASE
 		WHEN RIGHT( GROUP_CONCAT(is_project),1) =2 THEN GROUP_CONCAT(concat('其他:',wipr1.details))
@@ -1196,17 +1220,24 @@
 		left join rural_project_records rpr on rpr.id = wipr.project_id
 		left join project_report_data prds on rpr.id = prds.project_id
 		LEFT JOIN sys_user sua ON sua.id = a.account_checking_user_id
-		left join work_invoice_detail wid on a.id = wid.invoice_id
 		LEFT join sys_office so on so.id = a.office_id
 		LEFT join sys_area sa on sa.id = a.area_id
 		left join work_invoice_receipt wir on wir.invoice_id = a.id
 		<where>
 			a.del_flag = #{DEL_FLAG_NORMAL}
 			<if test="widNumber != null and widNumber != ''">
-				AND wid.number LIKE
-				<if test="dbName == 'oracle'">'%'||#{widNumber}||'%'</if>
-				<if test="dbName == 'mssql'">'%'+#{widNumber}+'%'</if>
-				<if test="dbName == 'mysql'">concat('%',#{widNumber},'%')</if>
+				AND EXISTS (
+				SELECT 1
+				FROM work_invoice_detail wid
+				<where>
+					a.id = wid.invoice_id
+
+					AND wid.number LIKE
+					<if test="dbName == 'oracle'">'%'||#{widNumber}||'%'</if>
+					<if test="dbName == 'mssql'">'%'+#{widNumber}+'%'</if>
+					<if test="dbName == 'mysql'">concat('%',#{widNumber},'%')</if>
+				</where>
+				)
 			</if>
 			<if test="moneyStr != null and moneyStr != ''">
 				AND a.money LIKE
@@ -1291,7 +1322,7 @@
 				ORDER BY ${page.orderBy}
 			</when>
 			<otherwise>
-				ORDER BY a.create_date DESC,a.number desc, wid.total_money+0 desc
+				ORDER BY a.create_date DESC,a.number desc
 			</otherwise>
 		</choose>
 	</select>