|
|
@@ -58,6 +58,57 @@
|
|
|
<collection property="financeInvoiceDetailDTOList" column="id" select="getFidList" ofType="com.jeeplus.assess.invoice.service.dto.FinanceInvoiceDetailDTO"></collection>
|
|
|
</resultMap>
|
|
|
|
|
|
+
|
|
|
+ <resultMap id="BaseExportResultMap" type="com.jeeplus.assess.invoice.service.dto.FinanceInvoiceDTO">
|
|
|
+ <id property="id" column="id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="createBy.id" column="create_by_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="updateBy.id" column="update_by_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
|
|
|
+ <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
|
|
+ <result property="type" column="type" jdbcType="VARCHAR"/>
|
|
|
+ <result property="no" column="no" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingType" column="billing_type" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingWorkplaceReal" column="billing_workplace_real" jdbcType="VARCHAR"/>
|
|
|
+ <result property="taxpayerIdentificationNo" column="taxpayer_identification_no" jdbcType="VARCHAR"/>
|
|
|
+ <result property="address" column="address" jdbcType="VARCHAR"/>
|
|
|
+ <result property="telPhone" column="tel_phone" jdbcType="VARCHAR"/>
|
|
|
+ <result property="openBank" column="open_bank" jdbcType="VARCHAR"/>
|
|
|
+ <result property="bankAccount" column="bank_account" jdbcType="VARCHAR"/>
|
|
|
+ <result property="name" column="name" jdbcType="VARCHAR"/>
|
|
|
+ <result property="receivablesType" column="receivables_type" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingContent" column="billing_content" jdbcType="VARCHAR"/>
|
|
|
+ <result property="account" column="account" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingContentTerms" column="billing_content_terms" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingPeople" column="billing_people" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingDate" column="billing_date" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="collectDate" column="collect_date" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="billingPeopleReal" column="billing_people_real" jdbcType="VARCHAR"/>
|
|
|
+ <result property="reconciliationPeople" column="reconciliation_people" jdbcType="VARCHAR"/>
|
|
|
+ <result property="reconciliationArea" column="reconciliation_area" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingWorkplaceRealId" column="billing_workplace_real_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="billingPeopleId" column="billing_people_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="status" column="status" jdbcType="VARCHAR"/>
|
|
|
+ <result property="procInsId" column="proc_ins_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="processDefinitionId" column="process_definition_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="receivablesStatus" column="receivables_status" jdbcType="VARCHAR"/>
|
|
|
+ <result property="invalidStatus" column="invalid_status" jdbcType="VARCHAR"/>
|
|
|
+ <result property="receivablesDate" column="receivables_date" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="operator" column="operator" jdbcType="VARCHAR"/>
|
|
|
+ <result property="operatorOffice" column="operator_office" jdbcType="VARCHAR"/>
|
|
|
+ <result property="taskId" column="task_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="taskIdInvalid" column="task_id_invalid" jdbcType="VARCHAR"/>
|
|
|
+ <result property="isMultiple" column="is_multiple" jdbcType="VARCHAR"/>
|
|
|
+ <result property="redInvoiceFlag" column="red_invoice_flag" jdbcType="VARCHAR"/>
|
|
|
+ <result property="redInvoiceRelevancyId" column="red_invoice_relevancy_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="redInvoiceRelevancyNumber" column="red_invoice_relevancy_number" jdbcType="VARCHAR"/>
|
|
|
+ <result property="relatedInvoice" column="related_invoice" jdbcType="VARCHAR"/>
|
|
|
+ <result property="situationDetail" column="situation_detail" jdbcType="VARCHAR"/>
|
|
|
+
|
|
|
+ <result property="actualDrawerEmailAddress" column="actual_drawer_email_address" jdbcType="VARCHAR"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
<sql id="FIR_Column_List">
|
|
|
fir.id,
|
|
|
fir.create_by_id,
|
|
|
@@ -249,19 +300,17 @@
|
|
|
where fib.del_flag = '0' and fib.invoice_id = ${id}
|
|
|
</select>
|
|
|
|
|
|
- <select id="findList" resultMap="BaseResultMap">
|
|
|
+ <select id="findList" resultMap="BaseExportResultMap">
|
|
|
select
|
|
|
<include refid="New_Base_Column_List"></include>,
|
|
|
+ -- 补全原有业务逻辑中缺失的account字段(ResultMap已有该字段映射)
|
|
|
+ CASE WHEN fibs.rn = 1 THEN fi.account ELSE 0 END AS account,
|
|
|
su.name as operator,
|
|
|
so.name as operator_office,
|
|
|
fibs.report_no,
|
|
|
fibs.program_no,
|
|
|
- -- 获取项目名称
|
|
|
- CASE
|
|
|
- WHEN fibs.program_id is null THEN concat('其他:', fibs.program_name)
|
|
|
- ELSE rpr1.name
|
|
|
- END as programName,
|
|
|
- -- 按行号匹配金额和账户信息,没有则显示0或空
|
|
|
+ -- 保留原有字段返回(ResultMap未映射不影响SQL执行,仅DTO不接收)
|
|
|
+ CASE WHEN fibs.program_id is null THEN concat('其他:', fibs.program_name) ELSE rpr1.name END as programName,
|
|
|
COALESCE(detail.amount, 0) as amount,
|
|
|
detail.account as accountDetail,
|
|
|
detail.number as number,
|
|
|
@@ -269,37 +318,38 @@
|
|
|
art_invalid.ID_ as task_id_invalid,
|
|
|
su1.name as reconciliationPeopleName
|
|
|
from (
|
|
|
- -- 为finance_invoice_base添加行号(兼容旧版MySQL)
|
|
|
+ -- 优化:MySQL5.7适配 - 先过滤+排序,再生成行号(减少临时表/文件排序)
|
|
|
select
|
|
|
fib.*,
|
|
|
@row_num := if(@prev_invoice_id = fib.invoice_id, @row_num + 1, 1) as rn,
|
|
|
@prev_invoice_id := fib.invoice_id
|
|
|
- from finance_invoice_base fib,
|
|
|
+ from (
|
|
|
+ SELECT * FROM finance_invoice_base WHERE del_flag = '0' ORDER BY invoice_id, id
|
|
|
+ ) fib,
|
|
|
(select @row_num := 0, @prev_invoice_id := null) as vars
|
|
|
- where fib.del_flag = '0'
|
|
|
- order by fib.invoice_id, fib.id
|
|
|
) fibs
|
|
|
left join program_project_list_info rpr1 on fibs.program_id = rpr1.id
|
|
|
- -- 关联主表
|
|
|
+ -- 关联主表(原有逻辑不变)
|
|
|
left join finance_invoice fi on fibs.invoice_id = fi.id
|
|
|
- -- 为finance_invoice_detail添加行号并关联(兼容旧版MySQL)
|
|
|
+ -- 优化明细表行号生成(MySQL5.7适配)
|
|
|
left join (
|
|
|
select
|
|
|
fid.*,
|
|
|
@row_num2 := if(@prev_invoice_id2 = fid.invoice_id, @row_num2 + 1, 1) as rn,
|
|
|
@prev_invoice_id2 := fid.invoice_id
|
|
|
- from finance_invoice_detail fid,
|
|
|
+ from (
|
|
|
+ SELECT * FROM finance_invoice_detail WHERE del_flag = '0' ORDER BY invoice_id, id
|
|
|
+ ) fid,
|
|
|
(select @row_num2 := 0, @prev_invoice_id2 := null) as vars2
|
|
|
- where fid.del_flag = '0'
|
|
|
- order by fid.invoice_id, fid.id
|
|
|
) detail on fibs.invoice_id = detail.invoice_id and fibs.rn = detail.rn
|
|
|
- -- 其他关联表
|
|
|
+ -- 原有关联表逻辑完全保留
|
|
|
left join sys_user su on fi.create_by_id = su.id and su.del_flag = '0'
|
|
|
left join sys_office so on su.office_id = so.id and so.del_flag = '0'
|
|
|
left join act_ru_task art on fi.proc_ins_id = art.PROC_INST_ID_
|
|
|
left join finance_invoice_invalid invalid on invalid.invoice_id = fi.id and invalid.del_flag = '0'
|
|
|
left join act_ru_task art_invalid on invalid.proc_ins_id = art_invalid.PROC_INST_ID_
|
|
|
left join sys_user su1 on su1.id = fi.reconciliation_people
|
|
|
+ -- 保留原有动态条件(MyBatis-Plus分页/过滤)
|
|
|
${ew.customSqlSegment}
|
|
|
</select>
|
|
|
|