|
@@ -529,6 +529,227 @@
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="findListExport" resultType="WorkInvoice" >
|
|
|
+ SELECT
|
|
|
+ a.id AS "id",
|
|
|
+ a.number AS "number",
|
|
|
+ a.process_instance_id AS "processInstanceId",
|
|
|
+ a.client_id AS "client.id",
|
|
|
+ a.project_id AS "project.id",
|
|
|
+ a.money AS "money",
|
|
|
+ a.money AS "moneyStr",
|
|
|
+ a.invoice_type AS "invoiceType",
|
|
|
+ (case when a.invoice_type = '1' then '专票' when a.invoice_type = '2' then '普票' else '' end) as invoiceTypeStr,
|
|
|
+ a.charge_type AS "chargeType",
|
|
|
+ a.content AS "content",
|
|
|
+ a.drawer_id AS "drawer.id",
|
|
|
+ a.office_id AS "office.id",
|
|
|
+ a.invoice_number AS "invoiceNumber",
|
|
|
+ a.invoice_date AS "invoiceDate",
|
|
|
+ a.drawer_name AS "drawerName",
|
|
|
+ a.take_date AS "takeDate",
|
|
|
+ a.invoice_remarks AS "invoiceRemarks",
|
|
|
+ a.is_invoice AS "isInvoice",
|
|
|
+ a.is_charge AS "isCharge",
|
|
|
+ a.is_invalid AS "isInvalid",
|
|
|
+ a.create_by AS "createBy.id",
|
|
|
+ a.create_date AS "createDate",
|
|
|
+ a.update_by AS "updateBy.id",
|
|
|
+ a.update_date AS "updateDate",
|
|
|
+ a.remarks AS "remarks",
|
|
|
+ a.del_flag AS "delFlag",
|
|
|
+ a.orUnicode AS "orUnicode",
|
|
|
+ a.address AS "address",
|
|
|
+ a.telephone AS "telephone",
|
|
|
+ a.bank AS "bank",
|
|
|
+ a.bank_number AS "bankNumber",
|
|
|
+ a.cancle_reason AS "cancaleReason",
|
|
|
+ u.name AS "drawer.name",
|
|
|
+ su.name AS "createBy.name",
|
|
|
+ so.top_company AS "office.name",
|
|
|
+ w.name AS "client.name",
|
|
|
+ p.project_name AS "project.projectName",
|
|
|
+ p.id AS "project.id",
|
|
|
+ a.invoice_state AS "invoiceState",
|
|
|
+ p.project_id AS "project.projectId",
|
|
|
+ ci.name AS "project.workContractInfo.name",
|
|
|
+ w.usc_code AS "client.uscCode",
|
|
|
+ w.fax AS "client.fax",
|
|
|
+ w.or_unicode AS "client.orUnicode",
|
|
|
+ w.telephone AS "client.telephone",
|
|
|
+ a.company_id AS "companyId",
|
|
|
+ a.cancle_reason AS "cancleReason",
|
|
|
+ w.address AS "client.address",
|
|
|
+ a.officee_id AS "officeId",
|
|
|
+ a.province AS "province",
|
|
|
+ a.ext AS "ext",
|
|
|
+ a.billing_content as "billingContent",
|
|
|
+ prd.number as "project.reportData.number",
|
|
|
+ p.area_name as "project.county",
|
|
|
+ a.receipt_money_date as "receiptMoneyDate",
|
|
|
+ (case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' else '否' end) as receiptMoney,
|
|
|
+ a.cancellation_remark as "cancellationRemark",
|
|
|
+ a.account_checking_user_id as "accountCheckingUserId",
|
|
|
+ a.area_id as "area.id",
|
|
|
+ acu.name as "accountCheckingUserName"
|
|
|
+ ,wid.number as "widNumber"
|
|
|
+ ,wid.total_money as "widTotalMoney"
|
|
|
+ ,(select
|
|
|
+ CASE
|
|
|
+ WHEN RIGHT( GROUP_CONCAT(is_project),1) =2 THEN GROUP_CONCAT(concat('其他:',wipr1.details))
|
|
|
+ WHEN RIGHT( GROUP_CONCAT(is_project),1) =1 THEN GROUP_CONCAT(rpr1.project_name)
|
|
|
+ ELSE '' END
|
|
|
+ FROM work_invoice_project_relation wipr1
|
|
|
+ LEFT JOIN rural_project_records rpr1 ON wipr1.project_id = rpr1.id
|
|
|
+ LEFT JOIN project_report_data prd1 ON prd1.project_id = wipr1.project_id
|
|
|
+ WHERE wipr1.invoice_id = a.id) as projectName
|
|
|
+ ,(select
|
|
|
+ GROUP_CONCAT(prd1.number)
|
|
|
+ FROM work_invoice_project_relation wipr1
|
|
|
+ LEFT JOIN rural_project_records rpr1 ON wipr1.project_id = rpr1.id
|
|
|
+ LEFT JOIN project_report_data prd1 ON prd1.project_id = wipr1.project_id
|
|
|
+ WHERE wipr1.invoice_id = a.id) as reportNumber
|
|
|
+ FROM work_invoice a
|
|
|
+ <include refid="workInvoiceJoins"/>
|
|
|
+ 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
|
|
|
+ <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}
|
|
|
+ </if>
|
|
|
+ <if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
|
|
|
+ AND a.create_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="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>
|
|
|
+ </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>
|
|
|
+ ${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>
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="getSumMoney" resultType="java.lang.String" >
|
|
|
select format(sum(x.money),2) as sumMoney
|
|
|
FROM (
|