|
|
@@ -533,6 +533,19 @@
|
|
|
,sa.name as "accountCheckingArea"
|
|
|
,ifnull(( SELECT wir.receipt_date FROM work_invoice_receipt wir WHERE wir.invoice_id = a.id ORDER BY wir.receipt_date DESC LIMIT 1 ),a.receipt_money_date) AS "receiptMoneyDate",
|
|
|
ifnull((select sum(wir.money) from work_invoice_receipt wir where wir.invoice_id = a.id ),0) as "receiptMoneyD"
|
|
|
+
|
|
|
+ ,(SELECT wi.id
|
|
|
+ FROM work_invoice wi
|
|
|
+ WHERE wi.red_invoice_relevancy_id = a.id
|
|
|
+ AND wi.del_flag = 0
|
|
|
+ LIMIT 1) AS byRedInvoiceRelevancyId
|
|
|
+
|
|
|
+ ,(SELECT wi.number
|
|
|
+ FROM work_invoice wi
|
|
|
+ WHERE wi.red_invoice_relevancy_id = a.id
|
|
|
+ AND wi.del_flag = 0
|
|
|
+ LIMIT 1) AS byRedInvoiceRelevancyNumber
|
|
|
+
|
|
|
FROM work_invoice a
|
|
|
LEFT JOIN sys_user su ON su.id = a.create_by
|
|
|
LEFT JOIN work_client_info w ON w.id = a.client_id
|
|
|
@@ -544,6 +557,48 @@
|
|
|
LEFT join sys_office so on so.id = a.office_id
|
|
|
LEFT JOIN sys_user sua ON sua.id = a.account_checking_user_id
|
|
|
left join sys_area sa on sa.id = a.area_id
|
|
|
+ <if test="isRedFlush != null">
|
|
|
+ <!-- 1:只红冲数据 -->
|
|
|
+ <if test="isRedFlush == 1">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ ) AS temp_inv ON a.id = temp_inv.id
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 2:只被红冲数据 -->
|
|
|
+ <if test="isRedFlush == 2">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_invoice ON a.id = temp_invoice.red_invoice_relevancy_id
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 3:全部(红冲 + 被红冲)-->
|
|
|
+ <if test="isRedFlush == 3">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ UNION
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_all ON a.id = temp_all.invoice_id
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 0:正常数据 → 这是唯一正确版 -->
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ LEFT JOIN work_invoice wi_refused
|
|
|
+ ON wi_refused.red_invoice_relevancy_id = a.id
|
|
|
+ AND wi_refused.money LIKE '%-%'
|
|
|
+ AND wi_refused.del_flag = 0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
<where>
|
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
|
|
|
|
@@ -615,6 +670,12 @@
|
|
|
AND a.invoice_date <= #{endContractDate}
|
|
|
</if>
|
|
|
|
|
|
+ <!-- 0:正常数据 → 这是唯一正确版 -->
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ AND a.money NOT LIKE '%-%'
|
|
|
+ AND wi_refused.id IS NULL
|
|
|
+ </if>
|
|
|
+
|
|
|
<if test="receiptBeginDate != null and receiptBeginDate != ''">
|
|
|
AND date_format(a.receipt_money_date,'%Y-%m-%d') >= date_format(#{receiptBeginDate},'%Y-%m-%d')
|
|
|
</if>
|
|
|
@@ -1252,6 +1313,48 @@
|
|
|
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
|
|
|
+ <if test="isRedFlush != null">
|
|
|
+ <!-- 1:只红冲数据 -->
|
|
|
+ <if test="isRedFlush == 1">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ ) AS temp_inv ON a.id = temp_inv.id
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 2:只被红冲数据 -->
|
|
|
+ <if test="isRedFlush == 2">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_invoice ON a.id = temp_invoice.red_invoice_relevancy_id
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 3:全部(红冲 + 被红冲)-->
|
|
|
+ <if test="isRedFlush == 3">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ UNION
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_all ON a.id = temp_all.invoice_id
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 0:正常数据 → 这是唯一正确版 -->
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ LEFT JOIN work_invoice wi_refused
|
|
|
+ ON wi_refused.red_invoice_relevancy_id = a.id
|
|
|
+ AND wi_refused.money LIKE '%-%'
|
|
|
+ AND wi_refused.del_flag = 0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
<where>
|
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
|
<if test="widNumber != null and widNumber != ''">
|
|
|
@@ -1330,6 +1433,12 @@
|
|
|
<if test="billingContent != null and billingContent != ''">
|
|
|
AND a.billing_content = #{billingContent}
|
|
|
</if>
|
|
|
+
|
|
|
+ <!-- 0:正常数据 → 这是唯一正确版 -->
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ AND a.money NOT LIKE '%-%'
|
|
|
+ AND wi_refused.id IS NULL
|
|
|
+ </if>
|
|
|
<if test="projectName != null and projectName != ''">
|
|
|
AND rpr.project_name LIKE
|
|
|
<if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
|
|
|
@@ -1359,242 +1468,333 @@
|
|
|
</choose>
|
|
|
</select>
|
|
|
|
|
|
-<select id="getSumMoney" resultType="java.lang.String" >
|
|
|
- select format(sum(x.money),2) as sumMoney
|
|
|
- FROM (
|
|
|
+ <select id="getSumMoney" resultType="java.lang.String" >
|
|
|
+ select format(sum(x.money),2) as sumMoney
|
|
|
+ FROM (
|
|
|
SELECT
|
|
|
- distinct (a.id) AS "id",a.money
|
|
|
- FROM work_invoice a
|
|
|
- LEFT JOIN sys_user su ON su.id = a.create_by
|
|
|
- LEFT JOIN work_client_info w ON w.id = a.client_id
|
|
|
- LEFT JOIN rural_project_records p ON p.id = a.project_id
|
|
|
- LEFT JOIN project_report_data prd ON p.id = prd.project_id
|
|
|
- left JOIN work_contract_info ci on ci.id = p.contract_id
|
|
|
- JOIN sys_office o ON o.id = a.office_id
|
|
|
- JOIN sys_office s ON s.id = a.company_id
|
|
|
- LEFT join sys_office so on so.id = a.office_id
|
|
|
- left join work_invoice_project_relation wipr on a.id = wipr.invoice_id
|
|
|
- left join rural_project_records rprs on wipr.project_id = rprs.id
|
|
|
- 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 work_invoice_detail wid on a.id = wid.invoice_id
|
|
|
- LEFT JOIN sys_user sua ON sua.id = a.account_checking_user_id
|
|
|
- left join sys_area sa on sa.id = a.area_id
|
|
|
- <where>
|
|
|
- a.del_flag = #{DEL_FLAG_NORMAL}
|
|
|
- and a.invoice_state !=4
|
|
|
- <if test="number != null and number != ''">
|
|
|
- AND a.number LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{number}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{number}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{number},'%')</if>
|
|
|
- </if>
|
|
|
- <if test="invoiceState != null and invoiceState != ''">
|
|
|
- AND (a.invoice_state = #{invoiceState} or a.cancellation_state = #{invoiceState})
|
|
|
- </if>
|
|
|
- <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
|
|
|
- AND a.invoice_date BETWEEN #{beginContractDate} AND #{endContractDate}
|
|
|
- </if>
|
|
|
+ distinct a.id AS id, a.money
|
|
|
+ FROM work_invoice a
|
|
|
|
|
|
- <if test="receiptBeginDate != null and receiptBeginDate != ''">
|
|
|
- AND date_format(a.receipt_money_date,'%Y-%m-%d') >= date_format(#{receiptBeginDate},'%Y-%m-%d')
|
|
|
- </if>
|
|
|
- <if test="receiptEndDate != null and receiptEndDate != ''">
|
|
|
- AND date_format(a.receipt_money_date,'%Y-%m-%d') <= date_format(#{receiptEndDate},'%Y-%m-%d')
|
|
|
+ <!-- 用到提交人才 JOIN -->
|
|
|
+ <if test="(submitterId != null and submitterId != '') or (submitterName != null and submitterName != '')">
|
|
|
+ LEFT JOIN sys_user su ON su.id = a.create_by
|
|
|
</if>
|
|
|
|
|
|
- <if test="client != null and client.id != null and client.id != ''">
|
|
|
- AND a.client_id = #{client.id}
|
|
|
+ <!-- 用到客户信息才 JOIN -->
|
|
|
+ <if test="(client != null and client.id != null and client.id != '')
|
|
|
+ or (client != null and client.name != null and client.name != '')">
|
|
|
+ LEFT JOIN work_client_info w ON w.id = a.client_id
|
|
|
</if>
|
|
|
- <if test="project != null and project.id != null and project.id != ''">
|
|
|
- AND a.project_id = #{project.id}
|
|
|
- </if>
|
|
|
- <if test="project != null and project.projectId != null and project.projectId != ''">
|
|
|
- AND p.project_id LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{project.projectId}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{project.projectId}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{project.projectId},'%')</if>
|
|
|
- </if>
|
|
|
- <if test="project != null and project.projectName != null and project.projectName != ''">
|
|
|
- AND p.project_name LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{project.projectName}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{project.projectName}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{project.projectName},'%')</if>
|
|
|
+
|
|
|
+ <!-- 用到项目才 JOIN -->
|
|
|
+ <if test="(project != null and project.id != null and project.id != '')
|
|
|
+ or (project != null and project.projectId != null and project.projectId != '')
|
|
|
+ or (project != null and project.projectName != null and project.projectName != '')">
|
|
|
+ LEFT JOIN rural_project_records p ON p.id = a.project_id
|
|
|
</if>
|
|
|
+
|
|
|
+ <!-- 用到项目报告编号才 JOIN -->
|
|
|
<if test="project != null and project.reportData != null and project.reportData.number != null and project.reportData.number != ''">
|
|
|
- AND prd.number LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{project.reportData.number}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{project.reportData.number}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{project.reportData.number},'%')</if>
|
|
|
- </if>
|
|
|
- <if test="client != null and client.name != null and client.name != ''">
|
|
|
- AND w.name LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{client.name}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{client.name}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{client.name},'%')</if>
|
|
|
- </if>
|
|
|
- <!--<if test="officeId != null and officeId != ''">
|
|
|
- AND so.id = #{officeId}
|
|
|
- </if>-->
|
|
|
- <if test="moneyStr != null and moneyStr != ''">
|
|
|
- AND a.money LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{moneyStr}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{moneyStr}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{moneyStr},'%')</if>
|
|
|
- </if>
|
|
|
- <!--<if test="submitterId != null and submitterId != ''">
|
|
|
- AND a.create_by = #{submitterId}
|
|
|
- </if>-->
|
|
|
- <if test="(submitterId != null and submitterId != '') or (submitterName != null and submitterName != '')">
|
|
|
- AND (a.create_by = #{submitterId} or su.name like concat('%',#{submitterName},'%'))
|
|
|
- </if>
|
|
|
- <if test="receiptMoney != null and receiptMoney != ''">
|
|
|
- AND a.receipt_money = #{receiptMoney}
|
|
|
- </if>
|
|
|
- <if test="invoiceType != null and invoiceType != ''">
|
|
|
- AND a.invoice_type = #{invoiceType}
|
|
|
- </if>
|
|
|
- <if test="chargeType != null and chargeType != ''">
|
|
|
- AND a.charge_type = #{chargeType}
|
|
|
- </if>
|
|
|
- <if test="content != null and content != ''">
|
|
|
- AND a.content = #{content}
|
|
|
- </if>
|
|
|
- <if test="drawer != null and drawer.id != null and drawer.id != ''">
|
|
|
- AND a.drawer_id = #{drawer.id}
|
|
|
- </if>
|
|
|
- <if test="companyId != null and companyId != ''">
|
|
|
- AND a.company_id = #{companyId}
|
|
|
- </if>
|
|
|
- <!--<if test="office != null and office.id != null and office.id != ''">
|
|
|
- AND a.office_id = #{office.id}
|
|
|
- </if>-->
|
|
|
- <if test="officeIdList!=null and officeIdList.size!=0">
|
|
|
- and a.office_id in
|
|
|
- <foreach collection="officeIdList" item="officeId" separator="," open="(" close=")">
|
|
|
- #{officeId}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="redNotStatusList!=null and redNotStatusList.size!=0">
|
|
|
- and a.invoice_state not in
|
|
|
- <foreach collection="redNotStatusList" item="status" separator="," open="(" close=")">
|
|
|
- #{status}
|
|
|
- </foreach>
|
|
|
+ LEFT JOIN project_report_data prd ON p.id = prd.project_id
|
|
|
</if>
|
|
|
+
|
|
|
+ <!-- 合同表 WHERE 没用到,直接删除 -->
|
|
|
+ <!-- left JOIN work_contract_info ci on ci.id = p.contract_id -->
|
|
|
+
|
|
|
+ <!-- 用到机构名称才 JOIN -->
|
|
|
<if test="officeId == '' and officeName!=null and officeName!=''">
|
|
|
- AND o.name like concat('%',#{officeName},'%')
|
|
|
- </if>
|
|
|
- <if test="invoiceNumber != null and invoiceNumber != ''">
|
|
|
- AND a.invoice_number LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{invoiceNumber}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{invoiceNumber}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{invoiceNumber},'%')</if>
|
|
|
- </if>
|
|
|
- <if test="invoiceDate != null and invoiceDate != ''">
|
|
|
- AND a.invoice_date = #{invoiceDate}
|
|
|
+ JOIN sys_office o ON o.id = a.office_id
|
|
|
</if>
|
|
|
- <if test="isInvoice != null and isInvoice != ''">
|
|
|
- AND a.is_invoice = #{isInvoice}
|
|
|
- </if>
|
|
|
- <if test="isCharge != null and isCharge != ''">
|
|
|
- AND a.is_charge = #{isCharge}
|
|
|
+
|
|
|
+ -- 公司表必须 JOIN
|
|
|
+ JOIN sys_office s ON s.id = a.company_id
|
|
|
+
|
|
|
+ <!-- 重复表,删除:LEFT join sys_office so on so.id = a.office_id -->
|
|
|
+
|
|
|
+ <!-- 用到 projectName / reportNumber 才关联 -->
|
|
|
+ <if test="projectName != null and projectName != '' or reportNumber != null and reportNumber != ''">
|
|
|
+ left join work_invoice_project_relation wipr on a.id = wipr.invoice_id
|
|
|
+ left join rural_project_records rpr on rpr.id = wipr.project_id
|
|
|
+ left join project_report_data prds on rpr.id = prds.project_id
|
|
|
</if>
|
|
|
- <if test="isInvalid != null and isInvalid != ''">
|
|
|
- AND a.is_invalid = #{isInvalid}
|
|
|
+
|
|
|
+ <!-- 用到 widNumber 才关联明细 -->
|
|
|
+ <if test="widNumber != null and widNumber != ''">
|
|
|
+ left join work_invoice_detail wid on a.id = wid.invoice_id
|
|
|
</if>
|
|
|
- <if test="billingContent != null and billingContent != ''">
|
|
|
- AND a.billing_content = #{billingContent}
|
|
|
+
|
|
|
+ <!-- 用到对账用户才关联 -->
|
|
|
+ <if test="(accountCheckingUserId != null and accountCheckingUserId != '') or (accountCheckingUserName != null and accountCheckingUserName != '')">
|
|
|
+ LEFT JOIN sys_user sua ON sua.id = a.account_checking_user_id
|
|
|
</if>
|
|
|
+
|
|
|
+ <!-- 用到区域才关联 -->
|
|
|
<if test="area != null and area.id != null and area.id != ''">
|
|
|
- AND (a.area_parent_id LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{area.id}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{area.id}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{area.id},'%')</if>
|
|
|
- or a.area_id = #{area.id}
|
|
|
- )
|
|
|
+ left join sys_area sa on sa.id = a.area_id
|
|
|
</if>
|
|
|
- <if test="(accountCheckingUserId != null and accountCheckingUserId != '') or (accountCheckingUserName != null and accountCheckingUserName != '')">
|
|
|
- AND (a.account_checking_user_id = #{accountCheckingUserId} or sua.name like concat('%',#{accountCheckingUserName},'%'))
|
|
|
+
|
|
|
+ <!-- 红冲逻辑不变 -->
|
|
|
+ <if test="isRedFlush != null">
|
|
|
+ <if test="isRedFlush == 1">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ ) AS temp_inv ON a.id = temp_inv.id
|
|
|
+ </if>
|
|
|
+ <if test="isRedFlush == 2">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_invoice ON a.id = temp_invoice.red_invoice_relevancy_id
|
|
|
+ </if>
|
|
|
+ <if test="isRedFlush == 3">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ UNION
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_all ON a.id = temp_all.invoice_id
|
|
|
+ </if>
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ LEFT JOIN work_invoice wi_refused
|
|
|
+ ON wi_refused.red_invoice_relevancy_id = a.id
|
|
|
+ AND wi_refused.money LIKE '%-%'
|
|
|
+ AND wi_refused.del_flag = 0
|
|
|
+ </if>
|
|
|
</if>
|
|
|
- <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>
|
|
|
+
|
|
|
+ <where>
|
|
|
+ a.del_flag = #{DEL_FLAG_NORMAL}
|
|
|
+ and a.invoice_state !=4
|
|
|
+
|
|
|
+ <if test="number != null and number != ''">
|
|
|
+ AND a.number LIKE concat('%',#{number},'%')
|
|
|
+ </if>
|
|
|
+ <if test="invoiceState != null and invoiceState != ''">
|
|
|
+ AND (a.invoice_state = #{invoiceState} or a.cancellation_state = #{invoiceState})
|
|
|
+ </if>
|
|
|
+ <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
|
|
|
+ AND a.invoice_date BETWEEN #{beginContractDate} AND #{endContractDate}
|
|
|
+ </if>
|
|
|
+ <if test="receiptBeginDate != null and receiptBeginDate != ''">
|
|
|
+ AND date_format(a.receipt_money_date,'%Y-%m-%d') >= date_format(#{receiptBeginDate},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="receiptEndDate != null and receiptEndDate != ''">
|
|
|
+ AND date_format(a.receipt_money_date,'%Y-%m-%d') <= date_format(#{receiptEndDate},'%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="client != null and client.id != null and client.id != ''">
|
|
|
+ AND a.client_id = #{client.id}
|
|
|
+ </if>
|
|
|
+ <if test="project != null and project.id != null and project.id != ''">
|
|
|
+ AND a.project_id = #{project.id}
|
|
|
+ </if>
|
|
|
+ <if test="project != null and project.projectId != null and project.projectId != ''">
|
|
|
+ AND p.project_id LIKE concat('%',#{project.projectId},'%')
|
|
|
+ </if>
|
|
|
+ <if test="project != null and project.projectName != null and project.projectName != ''">
|
|
|
+ AND p.project_name LIKE concat('%',#{project.projectName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="project != null and project.reportData != null and project.reportData.number != null and project.reportData.number != ''">
|
|
|
+ AND prd.number LIKE concat('%',#{project.reportData.number},'%')
|
|
|
+ </if>
|
|
|
+ <if test="client != null and client.name != null and client.name != ''">
|
|
|
+ AND w.name LIKE concat('%',#{client.name},'%')
|
|
|
+ </if>
|
|
|
+ <if test="moneyStr != null and moneyStr != ''">
|
|
|
+ AND a.money LIKE concat('%',#{moneyStr},'%')
|
|
|
+ </if>
|
|
|
+ <if test="(submitterId != null and submitterId != '') or (submitterName != null and submitterName != '')">
|
|
|
+ AND (a.create_by = #{submitterId} or su.name like concat('%',#{submitterName},'%'))
|
|
|
+ </if>
|
|
|
+ <if test="receiptMoney != null and receiptMoney != ''">
|
|
|
+ AND a.receipt_money = #{receiptMoney}
|
|
|
+ </if>
|
|
|
+ <if test="invoiceType != null and invoiceType != ''">
|
|
|
+ AND a.invoice_type = #{invoiceType}
|
|
|
+ </if>
|
|
|
+ <if test="chargeType != null and chargeType != ''">
|
|
|
+ AND a.charge_type = #{chargeType}
|
|
|
+ </if>
|
|
|
+ <if test="content != null and content != ''">
|
|
|
+ AND a.content = #{content}
|
|
|
+ </if>
|
|
|
+ <if test="drawer != null and drawer.id != null and drawer.id != ''">
|
|
|
+ AND a.drawer_id = #{drawer.id}
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null and companyId != ''">
|
|
|
+ AND a.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ AND a.money NOT LIKE '%-%'
|
|
|
+ AND wi_refused.id IS NULL
|
|
|
+ </if>
|
|
|
+ <if test="officeIdList!=null and officeIdList.size!=0">
|
|
|
+ and a.office_id in
|
|
|
+ <foreach collection="officeIdList" item="officeId" separator="," open="(" close=")">
|
|
|
+ #{officeId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="redNotStatusList!=null and redNotStatusList.size!=0">
|
|
|
+ and a.invoice_state not in
|
|
|
+ <foreach collection="redNotStatusList" item="status" separator="," open="(" close=")">
|
|
|
+ #{status}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="officeId == '' and officeName!=null and officeName!=''">
|
|
|
+ AND o.name like concat('%',#{officeName},'%')
|
|
|
+ </if>
|
|
|
+ <if test="invoiceNumber != null and invoiceNumber != ''">
|
|
|
+ AND a.invoice_number LIKE concat('%',#{invoiceNumber},'%')
|
|
|
+ </if>
|
|
|
+ <if test="invoiceDate != null and invoiceDate != ''">
|
|
|
+ AND a.invoice_date = #{invoiceDate}
|
|
|
+ </if>
|
|
|
+ <if test="isInvoice != null and isInvoice != ''">
|
|
|
+ AND a.is_invoice = #{isInvoice}
|
|
|
+ </if>
|
|
|
+ <if test="isCharge != null and isCharge != ''">
|
|
|
+ AND a.is_charge = #{isCharge}
|
|
|
+ </if>
|
|
|
+ <if test="isInvalid != null and isInvalid != ''">
|
|
|
+ AND a.is_invalid = #{isInvalid}
|
|
|
+ </if>
|
|
|
+ <if test="billingContent != null and billingContent != ''">
|
|
|
+ AND a.billing_content = #{billingContent}
|
|
|
+ </if>
|
|
|
+ <if test="area != null and area.id != null and area.id != ''">
|
|
|
+ AND (a.area_parent_id LIKE concat('%',#{area.id},'%') or a.area_id = #{area.id})
|
|
|
+ </if>
|
|
|
+ <if test="(accountCheckingUserId != null and accountCheckingUserId != '') or (accountCheckingUserName != null and accountCheckingUserName != '')">
|
|
|
+ AND (a.account_checking_user_id = #{accountCheckingUserId} or sua.name like concat('%',#{accountCheckingUserName},'%'))
|
|
|
+ </if>
|
|
|
+ <if test="widNumber != null and widNumber != ''">
|
|
|
+ AND wid.number LIKE concat('%',#{widNumber},'%')
|
|
|
+ </if>
|
|
|
+ <if test="newDrawerId != null and newDrawerId != ''">
|
|
|
+ and new_drawer_id like concat('%',#{newDrawerId},'%')
|
|
|
+ </if>
|
|
|
+ <if test="newDrawer != null and newDrawer != ''">
|
|
|
+ and new_drawer like concat('%',#{newDrawer},'%')
|
|
|
+ </if>
|
|
|
+ <if test="projectName != null and projectName != ''">
|
|
|
+ and (wipr.details like concat('%',#{projectName},'%') or rpr.project_name like concat('%',#{projectName},'%'))
|
|
|
+ </if>
|
|
|
+ <if test="reportNumber != null and reportNumber != ''">
|
|
|
+ and prds.number like concat('%',#{reportNumber},'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ ${sqlMap.dsf}
|
|
|
+ </where>
|
|
|
+ ) as x
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="queryCount" resultType="int" >
|
|
|
+ SELECT count(a.id)
|
|
|
+ FROM work_invoice a
|
|
|
+
|
|
|
+ <!-- 只有用到 su.name 才关联 sys_user -->
|
|
|
+ <if test="(submitterId != null and submitterId != '') or (submitterName != null and submitterName != '')">
|
|
|
+ LEFT JOIN sys_user su ON su.id = a.create_by
|
|
|
</if>
|
|
|
- <if test="newDrawerId != null and newDrawerId != ''">
|
|
|
- and new_drawer_id like
|
|
|
- <if test="dbName == 'oracle'">'%'||#{newDrawerId}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{newDrawerId}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{newDrawerId},'%')</if>
|
|
|
+
|
|
|
+ <!-- 只有用到客户名称/ID 才关联 work_client_info -->
|
|
|
+ <if test="(client != null and client.id != null and client.id != '')
|
|
|
+ or (client != null and client.name != null and client.name != '')">
|
|
|
+ LEFT JOIN work_client_info w ON w.id = a.client_id
|
|
|
</if>
|
|
|
- <if test="newDrawer != null and newDrawer != ''">
|
|
|
- and new_drawer like
|
|
|
- <if test="dbName == 'oracle'">'%'||#{newDrawer}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{newDrawer}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{newDrawer},'%')</if>
|
|
|
+
|
|
|
+ <!-- 只有用到项目相关条件才关联 rural_project_records -->
|
|
|
+ <if test="(project != null and project.id != null and project.id != '')
|
|
|
+ or (project != null and project.projectId != null and project.projectId != '')
|
|
|
+ or (project != null and project.projectName != null and project.projectName != '')">
|
|
|
+ LEFT JOIN rural_project_records p ON p.id = a.project_id
|
|
|
</if>
|
|
|
- <if test="projectName != null and projectName != ''">
|
|
|
- and (wipr.details like
|
|
|
- <if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{projectName}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{projectName},'%')</if>
|
|
|
- or rpr.project_name like
|
|
|
- <if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{projectName}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{projectName},'%')</if>
|
|
|
- )
|
|
|
+
|
|
|
+ <!-- 只有用到 project.reportData.number 才关联 project_report_data -->
|
|
|
+ <if test="project != null and project.reportData != null and project.reportData.number != null and project.reportData.number != ''">
|
|
|
+ LEFT JOIN project_report_data prd ON p.id = prd.project_id
|
|
|
</if>
|
|
|
- <if test="reportNumber != null and reportNumber != ''">
|
|
|
- and prds.number like
|
|
|
- <if test="dbName == 'oracle'">'%'||#{reportNumber}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{reportNumber}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{reportNumber},'%')</if>
|
|
|
+
|
|
|
+ <!-- 只有用到合同才关联(你这里没用到,直接删掉) -->
|
|
|
+ <!-- left JOIN work_contract_info ci on ci.id = p.contract_id -->
|
|
|
+
|
|
|
+ <!-- 只有用到 officeName 才关联 sys_office o -->
|
|
|
+ <if test="officeId == '' and officeName!=null and officeName!=''">
|
|
|
+ JOIN sys_office o ON o.id = a.office_id
|
|
|
</if>
|
|
|
|
|
|
+ <!-- 公司固定关联 -->
|
|
|
+ JOIN sys_office s ON s.id = a.company_id
|
|
|
|
|
|
- ${sqlMap.dsf}
|
|
|
- </where>
|
|
|
- ) as x
|
|
|
- </select>
|
|
|
+ <!-- 重复关联,删掉 LEFT join sys_office so on so.id = a.office_id -->
|
|
|
|
|
|
- <select id="queryCount" resultType="int" >
|
|
|
+ <!-- 只有用到对账用户才关联 sys_user sua -->
|
|
|
+ <if test="(accountCheckingUserId != null and accountCheckingUserId != '') or (accountCheckingUserName != null and accountCheckingUserName != '')">
|
|
|
+ LEFT JOIN sys_user sua ON sua.id = a.account_checking_user_id
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 红冲逻辑保持不变 -->
|
|
|
+ <if test="isRedFlush != null">
|
|
|
+ <if test="isRedFlush == 1">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ ) AS temp_inv ON a.id = temp_inv.id
|
|
|
+ </if>
|
|
|
+ <if test="isRedFlush == 2">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_invoice ON a.id = temp_invoice.red_invoice_relevancy_id
|
|
|
+ </if>
|
|
|
+ <if test="isRedFlush == 3">
|
|
|
+ INNER JOIN (
|
|
|
+ SELECT DISTINCT id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ UNION
|
|
|
+ SELECT DISTINCT red_invoice_relevancy_id AS invoice_id
|
|
|
+ FROM work_invoice
|
|
|
+ WHERE money LIKE '%-%'
|
|
|
+ AND red_invoice_relevancy_id IS NOT NULL
|
|
|
+ ) AS temp_all ON a.id = temp_all.invoice_id
|
|
|
+ </if>
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ LEFT JOIN work_invoice wi_refused
|
|
|
+ ON wi_refused.red_invoice_relevancy_id = a.id
|
|
|
+ AND wi_refused.money LIKE '%-%'
|
|
|
+ AND wi_refused.del_flag = 0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
|
|
|
- SELECT count((a.id))
|
|
|
- FROM work_invoice a
|
|
|
- LEFT JOIN sys_user su ON su.id = a.create_by
|
|
|
- LEFT JOIN work_client_info w ON w.id = a.client_id
|
|
|
- LEFT JOIN rural_project_records p ON p.id = a.project_id
|
|
|
- LEFT JOIN project_report_data prd ON p.id = prd.project_id
|
|
|
- left JOIN work_contract_info ci on ci.id = p.contract_id
|
|
|
- JOIN sys_office o ON o.id = a.office_id
|
|
|
- JOIN sys_office s ON s.id = a.company_id
|
|
|
- LEFT join sys_office so on so.id = a.office_id
|
|
|
- LEFT JOIN sys_user sua ON sua.id = a.account_checking_user_id
|
|
|
-<!-- <if test="client != null and client.name != null and client.name != ''">-->
|
|
|
-<!-- LEFT JOIN work_client_info w ON w.id = a.client_id-->
|
|
|
-<!-- </if>-->
|
|
|
-<!-- LEFT JOIN rural_project_records p ON p.id = a.project_id-->
|
|
|
-<!-- LEFT join sys_office so on so.id = a.office_id-->
|
|
|
-<!-- left join project_report_data prd on p.id = prd.project_id-->
|
|
|
<where>
|
|
|
a.del_flag = #{DEL_FLAG_NORMAL}
|
|
|
+
|
|
|
<if test="widNumber != null and widNumber != ''">
|
|
|
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>
|
|
|
+ WHERE a.id = wid.invoice_id
|
|
|
+ AND wid.number LIKE concat('%',#{widNumber},'%')
|
|
|
)
|
|
|
</if>
|
|
|
|
|
|
- <!-- 核心优化1:projectName 过滤(替换原有左连接逻辑) -->
|
|
|
+ <if test="isRedFlush == 0">
|
|
|
+ AND a.money NOT LIKE '%-%'
|
|
|
+ AND wi_refused.id IS NULL
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <!-- 下面所有 where 条件保持不变 -->
|
|
|
<if test="projectName != null and projectName != ''">
|
|
|
AND EXISTS (
|
|
|
SELECT 1
|
|
|
@@ -1602,20 +1802,12 @@
|
|
|
LEFT JOIN rural_project_records rpr ON wipr.project_id = rpr.id
|
|
|
WHERE a.id = wipr.invoice_id
|
|
|
AND (
|
|
|
- wipr.details LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{projectName}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{projectName},'%')</if>
|
|
|
+ wipr.details LIKE concat('%',#{projectName},'%')
|
|
|
OR
|
|
|
- rpr.project_name LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{projectName}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{projectName}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{projectName},'%')</if>
|
|
|
+ rpr.project_name LIKE concat('%',#{projectName},'%')
|
|
|
)
|
|
|
)
|
|
|
</if>
|
|
|
-
|
|
|
- <!-- 核心优化2:reportNumber 过滤(替换原有左连接逻辑) -->
|
|
|
<if test="reportNumber != null and reportNumber != ''">
|
|
|
AND EXISTS (
|
|
|
SELECT 1
|
|
|
@@ -1623,18 +1815,11 @@
|
|
|
LEFT JOIN rural_project_records rpr ON wipr.project_id = rpr.id
|
|
|
LEFT JOIN project_report_data prds ON rpr.id = prds.project_id
|
|
|
WHERE a.id = wipr.invoice_id
|
|
|
- AND prds.number LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{reportNumber}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{reportNumber}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{reportNumber},'%')</if>
|
|
|
+ AND prds.number LIKE concat('%',#{reportNumber},'%')
|
|
|
)
|
|
|
</if>
|
|
|
-
|
|
|
<if test="number != null and number != ''">
|
|
|
- AND a.number LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{number}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{number}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{number},'%')</if>
|
|
|
+ AND a.number LIKE concat('%',#{number},'%')
|
|
|
</if>
|
|
|
<if test="invoiceState != null and invoiceState != ''">
|
|
|
AND (a.invoice_state = #{invoiceState} or a.cancellation_state = #{invoiceState})
|
|
|
@@ -1645,14 +1830,12 @@
|
|
|
<if test="endContractDate != null">
|
|
|
AND a.invoice_date <= #{endContractDate}
|
|
|
</if>
|
|
|
-
|
|
|
<if test="receiptBeginDate != null and receiptBeginDate != ''">
|
|
|
AND date_format(a.receipt_money_date,'%Y-%m-%d') >= date_format(#{receiptBeginDate},'%Y-%m-%d')
|
|
|
</if>
|
|
|
<if test="receiptEndDate != null and receiptEndDate != ''">
|
|
|
AND date_format(a.receipt_money_date,'%Y-%m-%d') <= date_format(#{receiptEndDate},'%Y-%m-%d')
|
|
|
</if>
|
|
|
-
|
|
|
<if test="client != null and client.id != null and client.id != ''">
|
|
|
AND a.client_id = #{client.id}
|
|
|
</if>
|
|
|
@@ -1660,39 +1843,23 @@
|
|
|
AND a.project_id = #{project.id}
|
|
|
</if>
|
|
|
<if test="project != null and project.projectId != null and project.projectId != ''">
|
|
|
- AND p.project_id LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{project.projectId}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{project.projectId}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{project.projectId},'%')</if>
|
|
|
+ AND p.project_id LIKE concat('%',#{project.projectId},'%')
|
|
|
</if>
|
|
|
<if test="project != null and project.projectName != null and project.projectName != ''">
|
|
|
- AND p.project_name LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{project.projectName}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{project.projectName}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{project.projectName},'%')</if>
|
|
|
+ AND p.project_name LIKE concat('%',#{project.projectName},'%')
|
|
|
</if>
|
|
|
<if test="project != null and project.reportData != null and project.reportData.number != null and project.reportData.number != ''">
|
|
|
- AND prd.number LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{project.reportData.number}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{project.reportData.number}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{project.reportData.number},'%')</if>
|
|
|
+ AND prd.number LIKE concat('%',#{project.reportData.number},'%')
|
|
|
</if>
|
|
|
<if test="client != null and client.name != null and client.name != ''">
|
|
|
- AND w.name LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{client.name}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{client.name}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{client.name},'%')</if>
|
|
|
+ AND w.name LIKE concat('%',#{client.name},'%')
|
|
|
</if>
|
|
|
- <!--<if test="officeId != null and officeId != ''">
|
|
|
- AND so.id = #{officeId}
|
|
|
- </if>-->
|
|
|
<if test="officeIdList!=null and officeIdList.size!=0">
|
|
|
and a.office_id in
|
|
|
<foreach collection="officeIdList" item="officeId" separator="," open="(" close=")">
|
|
|
#{officeId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
-
|
|
|
<if test="redNotStatusList!=null and redNotStatusList.size!=0">
|
|
|
and a.invoice_state not in
|
|
|
<foreach collection="redNotStatusList" item="status" separator="," open="(" close=")">
|
|
|
@@ -1702,9 +1869,6 @@
|
|
|
<if test="officeId == '' and officeName!=null and officeName!=''">
|
|
|
AND o.name like concat('%',#{officeName},'%')
|
|
|
</if>
|
|
|
- <!--<if test="submitterId != null and submitterId != ''">
|
|
|
- AND a.create_by = #{submitterId}
|
|
|
- </if>-->
|
|
|
<if test="(submitterId != null and submitterId != '') or (submitterName != null and submitterName != '')">
|
|
|
AND (a.create_by = #{submitterId} or su.name like concat('%',#{submitterName},'%'))
|
|
|
</if>
|
|
|
@@ -1712,10 +1876,7 @@
|
|
|
AND a.receipt_money = #{receiptMoney}
|
|
|
</if>
|
|
|
<if test="moneyStr != null and moneyStr != ''">
|
|
|
- AND a.money LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{moneyStr}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{moneyStr}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{moneyStr},'%')</if>
|
|
|
+ AND a.money LIKE concat('%',#{moneyStr},'%')
|
|
|
</if>
|
|
|
<if test="invoiceType != null and invoiceType != ''">
|
|
|
AND a.invoice_type = #{invoiceType}
|
|
|
@@ -1739,10 +1900,7 @@
|
|
|
AND a.billing_content = #{billingContent}
|
|
|
</if>
|
|
|
<if test="invoiceNumber != null and invoiceNumber != ''">
|
|
|
- AND a.invoice_number LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{invoiceNumber}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{invoiceNumber}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{invoiceNumber},'%')</if>
|
|
|
+ AND a.invoice_number LIKE concat('%',#{invoiceNumber},'%')
|
|
|
</if>
|
|
|
<if test="invoiceDate != null and invoiceDate != ''">
|
|
|
AND a.invoice_date = #{invoiceDate}
|
|
|
@@ -1757,30 +1915,19 @@
|
|
|
AND a.is_invalid = #{isInvalid}
|
|
|
</if>
|
|
|
<if test="area != null and area.id != null and area.id != ''">
|
|
|
- AND (a.area_parent_id LIKE
|
|
|
- <if test="dbName == 'oracle'">'%'||#{area.id}||'%'</if>
|
|
|
- <if test="dbName == 'mssql'">'%'+#{area.id}+'%'</if>
|
|
|
- <if test="dbName == 'mysql'">concat('%',#{area.id},'%')</if>
|
|
|
- or a.area_id = #{area.id}
|
|
|
- )
|
|
|
+ AND (a.area_parent_id LIKE concat('%',#{area.id},'%') or a.area_id = #{area.id})
|
|
|
</if>
|
|
|
<if test="(accountCheckingUserId != null and accountCheckingUserId != '') or (accountCheckingUserName != null and accountCheckingUserName != '')">
|
|
|
AND (a.account_checking_user_id = #{accountCheckingUserId} or sua.name like concat('%',#{accountCheckingUserName},'%'))
|
|
|
</if>
|
|
|
-
|
|
|
<if test="isOmsBilling != null">
|
|
|
AND a.is_oms_billing = #{isOmsBilling}
|
|
|
</if>
|
|
|
${sqlMap.dsf}
|
|
|
</where>
|
|
|
- <choose>
|
|
|
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
|
|
- ORDER BY ${page.orderBy}
|
|
|
- </when>
|
|
|
- <otherwise>
|
|
|
- ORDER BY a.create_date DESC
|
|
|
- </otherwise>
|
|
|
- </choose>
|
|
|
+
|
|
|
+ <!-- count 不需要排序,直接去掉,提升性能 -->
|
|
|
+ <!-- ORDER BY 去掉 -->
|
|
|
</select>
|
|
|
<select id="queryMapCount" resultType="int" >
|
|
|
SELECT count(1)
|