|
@@ -1070,127 +1070,184 @@
|
|
|
FROM (
|
|
|
SELECT
|
|
|
distinct (a.id) AS "id",a.money
|
|
|
- FROM work_invoice a
|
|
|
- <include refid="workInvoiceJoins"/>
|
|
|
- left join work_invoice_detail wid on a.id = wid.invoice_id
|
|
|
- <where>
|
|
|
- a.del_flag = #{DEL_FLAG_NORMAL}
|
|
|
- and a.invoice_state = 5
|
|
|
- <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="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="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
|
|
|
- AND a.invoice_date BETWEEN #{beginContractDate} AND #{endContractDate}
|
|
|
- </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
|
|
|
- <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>
|
|
|
- </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>
|
|
|
- </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="money != null and money != ''">
|
|
|
- AND a.money = #{money}
|
|
|
- </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="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}
|
|
|
- </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
|
|
|
- <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}
|
|
|
- )
|
|
|
- </if>
|
|
|
- <if test="(accountCheckingUserId != null and accountCheckingUserId != '') or (accountCheckingUserName != null and accountCheckingUserName != '')">
|
|
|
- AND (a.account_checking_user_id = #{accountCheckingUserId} or acu.name like concat('%',#{accountCheckingUserName},'%'))
|
|
|
- </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>
|
|
|
- </if>
|
|
|
- ${sqlMap.dsf}
|
|
|
- </where>
|
|
|
+ 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}
|
|
|
+ <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>
|
|
|
+
|
|
|
+ <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
|
|
|
+ <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>
|
|
|
+ </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>
|
|
|
+ </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="money != null and money != ''">
|
|
|
+ AND a.money = #{money}
|
|
|
+ </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="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}
|
|
|
+ </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
|
|
|
+ <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}
|
|
|
+ )
|
|
|
+ </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
|
|
|
+ <if test="dbName == 'oracle'">'%'||#{widNumber}||'%'</if>
|
|
|
+ <if test="dbName == 'mssql'">'%'+#{widNumber}+'%'</if>
|
|
|
+ <if test="dbName == 'mysql'">concat('%',#{widNumber},'%')</if>
|
|
|
+ </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>
|
|
|
+ </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>
|
|
|
+ </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>
|
|
|
+ )
|
|
|
+ </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>
|
|
|
+ </if>
|
|
|
+
|
|
|
+
|
|
|
+ ${sqlMap.dsf}
|
|
|
+ </where>
|
|
|
) as x
|
|
|
</select>
|
|
|
|