Merge pull request 'demand: TMS系统 - 客户账单管理 - 财务开票处理-定制导出性能优化' (#220) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/220
This commit is contained in:
heyu 2025-11-05 17:18:13 +08:00
commit 91de511e88
9 changed files with 278 additions and 9 deletions

View File

@ -52,6 +52,16 @@ public interface EmisSettleBillMapper extends BaseMapper<EmisSettleBill>
@Param("settleBillNoList") List<String> settleBillNoList);
/**
* 批量查询
*
* @param settleBillNoList 结算账单号列表
* @return 结算账单列表
*/
public List<EmisSettleBill> selectSimpleBillsByNos(
@Param("settleBillNoList") List<String> settleBillNoList);
/**
* 获取统计数据
* @param emisSettleBill

View File

@ -110,4 +110,14 @@ public interface EmisSettleInvoiceRecordMapper extends BaseMapper<EmisSettleInvo
*/
public List<EmisSettleInvoiceRecord> selectInvoiceRecordListByBillCodes(@Param("billCodes") List<String> billCodes);
/**
* 查询开票记录列表(简化版,不包含association查询)
* 用于导出等场景,只查询必要的字段
*
* @param emisSettleInvoiceRecord
* @return 集合
*/
public List<EmisSettleInvoiceRecord> selectSimpleInvoiceRecordList(
EmisSettleInvoiceRecord emisSettleInvoiceRecord);
}

View File

@ -13,6 +13,7 @@ package com.xdadan.erp.emis.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.emis.domain.EmisSettlePayBillRel;
import org.apache.ibatis.annotations.Param;
/**
* @ClassName EmisSettlePayBillRelMapper
* @Description <p> 付款账单关联表 Mapper 接口 </p>
@ -36,6 +37,15 @@ public interface EmisSettlePayBillRelMapper extends BaseMapper<EmisSettlePayBill
*/
public List<EmisSettlePayBillRel> selectEmisSettlePayBillRelList(EmisSettlePayBillRel emisSettlePayBillRel);
/**
* 根据结算账单号列表查询支付账单关联记录
*
* @param settleBillNoList 结算账单号列表
* @return 支付账单关联记录列表
*/
public List<EmisSettlePayBillRel> selectEmisSettlePayBillRelListBySettleBillNos(
@Param("settleBillNoList") List<String> settleBillNoList);
/**
* 检查是否重复

View File

@ -340,6 +340,14 @@ public interface EmisWaybillMapper extends BaseMapper<EmisWaybill>
*/
List<EmisWaybill> selectEmisWaybillListByBillCodes(@Param("billCodes") List<String> billCodes);
/**
* 只查询运单表数据
*
* @param billCodes 运单号列表
* @return 运单列表
*/
List<EmisWaybill> selectWaybillsByBillCodes(@Param("billCodes") List<String> billCodes);
/**
*
* @param offset

View File

@ -405,7 +405,7 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
EmisSettleInvoiceRecord emisSettleInvoiceRecord) {
// 查询开票记录列表
List<EmisSettleInvoiceRecord> invoiceRecordList = emisSettleInvoiceRecordMapper
.selectEmisSettleInvoiceRecordList(emisSettleInvoiceRecord);
.selectSimpleInvoiceRecordList(emisSettleInvoiceRecord);
if (CollectionUtils.isEmpty(invoiceRecordList)) {
return new ArrayList<>();
@ -453,12 +453,11 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
}
// 查询 payId 到 settleBillNo 的映射关系
if (!allPayIdSet.isEmpty()) {
// 查询所有相关的支付账单关联记录(只查询del_flag='0'的记录)
EmisSettlePayBillRel queryPayBillRel = new EmisSettlePayBillRel();
queryPayBillRel.setDelFlag("0");
if (!allPayIdSet.isEmpty() && !allSettleBillNoSet.isEmpty()) {
// 根据allSettleBillNoSet批量查询相关的支付账单关联记录
List<String> settleBillNoList = new ArrayList<>(allSettleBillNoSet);
List<EmisSettlePayBillRel> payBillRelList = emisSettlePayBillRelMapper
.selectEmisSettlePayBillRelList(queryPayBillRel);
.selectEmisSettlePayBillRelListBySettleBillNos(settleBillNoList);
// 建立 payId -> Set<settleBillNo> 的映射(只处理相关的payId和settleBillNo)
for (EmisSettlePayBillRel payBillRel : payBillRelList) {
@ -515,7 +514,7 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
if (!allSettleBillNoSet.isEmpty()) {
List<String> settleBillNoList = new ArrayList<>(allSettleBillNoSet);
List<EmisSettleBill> settleBillList = emisSettleBillMapper
.selectSettleBillBySettleBillNoList(settleBillNoList);
.selectSimpleBillsByNos(settleBillNoList);
for (EmisSettleBill settleBill : settleBillList) {
if (StringUtils.isNotBlank(settleBill.getSettleBillNo())) {
settleBillMap.put(settleBill.getSettleBillNo(), settleBill);
@ -541,7 +540,7 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
Map<String, EmisWaybill> waybillMap = new HashMap<>();
if (!allBillNoSet.isEmpty()) {
List<String> billNoList = new ArrayList<>(allBillNoSet);
List<EmisWaybill> waybillList = emisWaybillMapper.selectEmisWaybillListByBillCodes(billNoList);
List<EmisWaybill> waybillList = emisWaybillMapper.selectWaybillsByBillCodes(billNoList);
for (EmisWaybill waybill : waybillList) {
if (StringUtils.isNotBlank(waybill.getBillCode())) {
waybillMap.put(waybill.getBillCode(), waybill);

View File

@ -66,6 +66,61 @@
</resultMap>
<!-- 简化版resultMap -->
<resultMap type="EmisSettleBill" id="EmisSettleBillSimpleResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="settleBillNo" column="settle_bill_no" />
<result property="settleBillName" column="settle_bill_name" />
<result property="settleType" column="settle_type" />
<result property="settleStartDate" column="settle_start_date" />
<result property="settleEndDate" column="settle_end_date" />
<result property="billMonth" column="bill_month" />
<result property="recMoney" column="rec_money" />
<result property="recedMoney" column="reced_money" />
<result property="invoicedMoney" column="invoiced_money" />
<result property="custNo" column="cust_no" />
<result property="custName" column="cust_name" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
<result property="siteCode" column="site_code" />
<result property="siteName" column="site_name" />
<result property="satisfyMoney" column="satisfy_money" />
<result property="allowanceMoney" column="allowance_money" />
<result property="deductionMoney" column="deduction_money" />
<result property="otherMoney" column="other_money" />
<result property="satisfyReason" column="satisfy_reason" />
<result property="allowanceReason" column="allowance_reason" />
<result property="deductionReason" column="deduction_reason" />
<result property="otherReason" column="other_reason" />
<result property="openBillStatus" column="open_bill_status" />
<result property="paymentStatus" column="payment_status" />
<result property="chargeStatus" column="charge_status" />
<result property="sendPieceSum" column="send_piece_sum" />
<result property="pieceNumber" column="piece_number" />
<result property="feeWeight" column="fee_weight" />
<result property="uncollectedAmount" column="uncollected_amount" />
<result property="sendMoneySum" column="send_money_sum" />
<result property="refundAmount" column="refund_amount" />
<result property="refundMoney" column="refund_money" />
<result property="payee" column="payee" />
<result property="salesmen" column="salesmen" />
<result property="creditPeriod" column="credit_period" />
<result property="creditPeriodType" column="credit_period_type" />
<result property="settleDay" column="settle_day" />
<result property="paymentDueDate" column="payment_due_date" />
<result property="blSendOms" column="bl_send_oms" />
<result property="blConfirmCenter" column="bl_confirm_center" />
<result property="confirmCenterDate" column="confirm_center_date" />
<result property="confirmCenterNote" column="confirm_center_note" />
<result property="confirmCenterManCode" column="confirm_center_man_code" />
<result property="confirmCenterCode" column="confirm_center_code" />
<result property="blConfirmSite" column="bl_confirm_site" />
<result property="confirmSiteDate" column="confirm_site_date" />
<result property="confirmSiteManCode" column="confirm_site_man_code" />
<result property="confirmSiteNote" column="confirm_site_note" />
<result property="confirmSiteCode" column="confirm_site_code" />
</resultMap>
<resultMap type="BillPayStatInfo" id="BillPayStatInfoResult">
<result property="salesmen" column="salesmen" />
@ -1029,6 +1084,15 @@
</foreach>
</select>
<select id="selectSimpleBillsByNos" parameterType="List" resultMap="EmisSettleBillSimpleResult">
select id, settle_bill_no, settle_bill_name, settle_type, settle_start_date, settle_end_date, bill_month, rec_money, reced_money, invoiced_money, cust_no, cust_name, customer_code, customer_name, site_code, site_name, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, send_piece_sum, piece_number, fee_weight, uncollected_amount, send_money_sum, refund_amount, refund_money, payee, salesmen, credit_period, credit_period_type, settle_day, payment_due_date, bl_send_oms, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_bill a
where a.del_flag='0' and a.settle_bill_no in
<foreach item="settleBillNo" collection="settleBillNoList" open="(" separator="," close=")">
#{settleBillNo}
</foreach>
</select>
<insert id="insertEmisSettleBill" parameterType="EmisSettleBill" useGeneratedKeys="true" keyProperty="id">
insert into emis_settle_bill
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -1227,4 +1291,4 @@
#{id}
</foreach>
</delete>
</mapper>
</mapper>

View File

@ -65,6 +65,28 @@
</resultMap>
<!-- 简化版resultMap -->
<resultMap type="EmisSettleInvoiceRecord" id="EmisSettleInvoiceRecordSimpleResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="applySeqNo" column="apply_seq_no" />
<result property="applyDate" column="apply_date" />
<result property="applyManCode" column="apply_man_code" />
<result property="applyManName" column="apply_man_name" />
<result property="applyMoney" column="apply_money" />
<result property="opDate" column="op_date" />
<result property="opManCode" column="op_man_code" />
<result property="opManName" column="op_man_name" />
<result property="auditManCode" column="audit_man_code" />
<result property="auditManName" column="audit_man_name" />
<result property="companyName" column="company_name" />
<result property="invoiceNo" column="invoice_no" />
<result property="invoiceStatus" column="invoice_status" />
<result property="recedMoney" column="reced_money" />
<result property="paymentStatus" column="payment_status" />
<result property="settleBillNo" column="settle_bill_no" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectEmisSettleInvoiceRecordVo">
select id, apply_seq_no, apply_date, apply_man_code, apply_site_code, customer_code, customer_name, settle_bill_no, settle_bill_name, apply_money, invoice_type, openbill_scope, company_name, company_tax_no, company_tel, company_address, invioce_remark, bank_name, bank_acc_no, contact, phone, real_tax_type, orig_open_money, add_tax_rate, add_open_money, open_money_max, open_money, invoice_no, reced_money, payment_status, invoice_status, invoice_status_desc, recieve_address, email, file_path, remark, bl_audit, audit_date, audit_man_code, audit_site_code, audit_note, op_man_code, op_date, op_site_code, open_ch_id, open_ch_status, open_ch_status_desc, open_com_code, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_invoice_record
</sql>
@ -216,6 +238,129 @@
order by a.create_time desc
</select>
<select id="selectSimpleInvoiceRecordList" parameterType="EmisSettleInvoiceRecord"
resultMap="EmisSettleInvoiceRecordSimpleResult">
select a.id, a.apply_seq_no, a.apply_date, a.apply_man_code, a.apply_site_code, a.customer_code,
a.customer_name, a.settle_bill_no, a.settle_bill_name, a.apply_money, a.invoice_type, a.openbill_scope,
a.company_name, a.company_tax_no, a.company_tel, a.company_address, a.invioce_remark, a.bank_name,
a.bank_acc_no, a.contact, a.phone, a.real_tax_type, a.orig_open_money, a.add_tax_rate, a.add_open_money,
a.open_money_max, a.open_money, ch.invoice_no, a.reced_money, a.payment_status, a.invoice_status,
a.invoice_status_desc, a.recieve_address, a.email, a.file_path, a.remark, a.bl_audit, a.audit_date,
a.audit_man_code, a.audit_site_code, a.audit_note, a.op_man_code, a.op_date, a.op_site_code, a.open_ch_id,
a.open_ch_status, a.open_ch_status_desc, a.open_com_code, a.del_flag, a.create_by, a.create_time, a.update_by,
a.update_time, a.create_site, a.update_site,
apply_user.emp_name as apply_man_name,
audit_user.emp_name as audit_man_name,
op_user.emp_name as op_man_name
from emis_settle_invoice_record a
left join emis_settle_invoice_ch_record ch on a.apply_seq_no = ch.apply_seq_no and ch.del_flag = '0'
left join sys_user apply_user on a.apply_man_code = apply_user.emp_code
left join sys_user audit_user on a.audit_man_code = audit_user.emp_code
left join sys_user op_user on a.op_man_code = op_user.emp_code
<where>
a.del_flag='0'
<if test="id != null "> and a.id = #{id}</if>
<if test="applySeqNo != null and applySeqNo != ''"> and a.apply_seq_no = #{applySeqNo}</if>
<if test="applyDate != null "> and a.apply_date = #{applyDate}</if>
<if test="applyManCode != null and applyManCode != ''"> and a.apply_man_code = #{applyManCode}</if>
<if test="applySiteCode != null and applySiteCode != ''"> and a.apply_site_code = #{applySiteCode}</if>
<if test="customerCode != null and customerCode != ''"> and a.customer_code = #{customerCode}</if>
<if test="customerName != null and customerName != ''"> and a.customer_name like concat('%', #{customerName}, '%')</if>
<if test="settleBillName != null and settleBillName != ''"> and a.settle_bill_name like concat('%', #{settleBillName}, '%')</if>
<if test="applyMoney != null "> and a.apply_money = #{applyMoney}</if>
<if test="paymentStatus != null and paymentStatus != ''"> and a.payment_status=#{paymentStatus}</if>
<if test="invoiceType != null and invoiceType != ''"> and a.invoice_type = #{invoiceType}</if>
<if test="companyName != null and companyName != ''"> and a.company_name like concat('%', #{companyName}, '%')</if>
<if test="companyTaxNo != null and companyTaxNo != ''"> and a.company_tax_no = #{companyTaxNo}</if>
<if test="companyTel != null and companyTel != ''"> and a.company_tel like concat('%', #{companyTel}, '%')</if>
<if test="companyAddress != null and companyAddress != ''"> and a.company_address like concat('%', #{companyAddress}, '%')</if>
<if test="bankName != null and bankName != ''"> and a.bank_name like concat('%', #{bankName}, '%')</if>
<if test="bankAccNo != null and bankAccNo != ''"> and a.bank_acc_no like concat('%', #{bankAccNo}, '%')</if>
<if test="contact != null and contact != ''"> and a.contact like concat('%', #{contact}, '%')</if>
<if test="phone != null and phone != ''"> and a.phone like concat('%', #{phone}, '%')</if>
<if test="realTaxType != null and realTaxType != ''"> and a.real_tax_type = #{realTaxType}</if>
<if test="openMoneyMax != null "> and a.open_money_max = #{openMoneyMax}</if>
<if test="openMoney != null "> and a.open_money = #{openMoney}</if>
<if test="invoiceNo != null and invoiceNo != ''"> and FIND_IN_SET(ch.invoice_no, REPLACE(#{invoiceNo}, '\n', ','))</if>
<if test="invoiceStatus != null and invoiceStatus != ''"> and a.invoice_status = #{invoiceStatus}</if>
<if test="invoiceStatusDesc != null and invoiceStatusDesc != ''"> and a.invoice_status_desc like concat('%', #{invoiceStatusDesc}, '%')</if>
<if test="recieveAddress != null and recieveAddress != ''"> and a.recieve_address like concat('%', #{recieveAddress}, '%')</if>
<if test="email != null and email != ''"> and a.email like concat('%', #{email}, '%')</if>
<if test="filePath != null and filePath != ''"> and a.file_path like concat('%', #{filePath}, '%')</if>
<if test="remark != null and remark != ''"> and a.remark like concat('%', #{remark}, '%')</if>
<if test="blAudit != null and blAudit != ''"> and a.bl_audit = #{blAudit}</if>
<if test="auditDate != null "> and a.audit_date = #{auditDate}</if>
<if test="auditManCode != null and auditManCode != ''"> and a.audit_man_code like concat('%', #{auditManCode}, '%')</if>
<if test="auditSiteCode != null and auditSiteCode != ''"> and a.audit_site_code like concat('%', #{auditSiteCode}, '%')</if>
<if test="opManCode != null and opManCode != ''"> and a.op_man_code like concat('%', #{opManCode}, '%')</if>
<if test="opDate != null "> and a.op_date = #{opDate}</if>
<if test="opSiteCode != null and opSiteCode != ''"> and a.op_site_code = #{opSiteCode}</if>
<if test="openChId != null and openChId != ''"> and a.open_ch_id = #{openChId}</if>
<if test="openChStatus != null and openChStatus != ''"> and a.open_ch_status = #{openChStatus}</if>
<if test="openChStatusDesc != null and openChStatusDesc != ''"> and a.open_ch_status_desc = #{openChStatusDesc}</if>
<if test="openComCode != null and openComCode != ''"> and a.open_com_code = #{openComCode}</if>
<if test="delFlag != null and delFlag != ''"> and a.del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and a.create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and a.create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and a.update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and a.update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and a.create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and a.update_site like concat('%', #{updateSite}, '%')</if>
<if test="settleBillNo != null and settleBillNo != ''">
and EXISTS(
select 1 from emis_settle_invoice_bill_rel x3
where x3.del_flag = '0'
and a.apply_seq_no=x3.apply_seq_no
AND FIND_IN_SET(x3.settle_bill_no, #{settleBillNo})
)
</if>
<if test="params.billCode != null and params.billCode != ''">
and EXISTS(
select 1 from emis_settle_invoice_rel rel
where rel.del_flag = '0' and rel.bill_no=#{params.billCode}
and rel.apply_seq_no = a.apply_seq_no
)
</if>
<if test="params.beginApplyDate != null and params.beginApplyDate != ''">
and a.apply_date <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endApplyDate != null and params.endApplyDate != ''">
and a.apply_date <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''">
and a.create_time <![CDATA[ >= ]]> #{params.beginCreateTime}
</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''">
and a.create_time <![CDATA[ <= ]]> #{params.endCreateTime}
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and EXISTS(
select 1 from emis_settle_bill x2,emis_settle_invoice_bill_rel x3
where x2.del_flag = '0' and x3.del_flag = '0'
and a.apply_seq_no=x3.apply_seq_no and x2.settle_bill_no=x3.settle_bill_no
AND (
x2.salesmen = #{params.privEmpName}
OR x2.payee = #{params.privEmpName}
OR x2.salesmen IN (
SELECT salesmen
FROM emis_salesmen_rel esr
where esr.del_flag='0' and esr.bl_open='1'
and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date
and esr.sales_ass = #{params.privEmpName}
)
)
)
</if>
</where>
order by a.create_time desc
</select>
<select id="selectInvoiceRecordListBySettleBillNo" parameterType="String" resultMap="EmisSettleInvoiceRecordResult">
select id, apply_seq_no, apply_date, apply_man_code, apply_site_code, customer_code, customer_name, settle_bill_no, settle_bill_name, apply_money, invoice_type, company_name, company_tax_no, company_tel, company_address, bank_name, bank_acc_no, contact, phone, real_tax_type, open_money_max, open_money, invoice_no, invoice_status, invoice_status_desc, recieve_address, email, file_path, remark, bl_audit, audit_date, audit_man_code, audit_site_code, audit_note, op_man_code, op_date, op_site_code, open_ch_id, open_ch_status, open_ch_status_desc, open_com_code, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_invoice_record a

View File

@ -32,6 +32,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by create_time desc
</select>
<select id="selectEmisSettlePayBillRelListBySettleBillNos" parameterType="List" resultMap="EmisSettlePayBillRelResult">
<include refid="selectEmisSettlePayBillRelVo"/>
<where>
del_flag='0'
<if test="settleBillNoList != null and settleBillNoList.size() > 0">
and settle_bill_no in
<foreach item="settleBillNo" collection="settleBillNoList" open="(" separator="," close=")">
#{settleBillNo}
</foreach>
</if>
</where>
order by create_time desc
</select>
<select id="checkUnique" parameterType="EmisSettlePayBillRel" resultType="int">
select count(1) from emis_settle_pay_bill_rel
where del_flag='0'

View File

@ -621,6 +621,15 @@
</foreach>
</select>
<select id="selectWaybillsByBillCodes" parameterType="java.util.List" resultMap="EmisWaybillResult">
select * from emis_waybill
where del_flag = '0'
and bill_code in
<foreach collection="billCodes" item="billCode" open="(" separator="," close=")">
#{billCode}
</foreach>
</select>
<select id="selectWaitGotOrderList" parameterType="EmisWaybill" resultMap="EmisWaybillResult">
<include refid="selectEmisWaybillVo"/>
<where>