demand: TMS-财务中心销账审核:列表数据展示增添字段
This commit is contained in:
parent
4833abe27f
commit
fee685fd37
@ -19,6 +19,7 @@ import com.xdadan.erp.emis.domain.EmisWriteoffApplyDetail;
|
||||
import com.xdadan.erp.emis.domain.EmisSalesmenRel;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.service.IEmisWriteoffApplyService;
|
||||
import com.xdadan.erp.emis.service.IEmisSettleInvoiceRecordService;
|
||||
import com.xdadan.erp.emis.service.IEmisSalesmenRelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -47,6 +48,9 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
@Autowired
|
||||
private IEmisSalesmenRelService emisSalesmenRelService;
|
||||
|
||||
@Autowired
|
||||
private IEmisSettleInvoiceRecordService emisSettleInvoiceRecordService;
|
||||
|
||||
/**
|
||||
* 查询销账申请列表
|
||||
*/
|
||||
@ -59,6 +63,12 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
|
||||
setPrivParams(emisWriteoffApply);
|
||||
|
||||
// 支持按发票号查询:将多行发票号格式化为逗号分隔
|
||||
if (emisWriteoffApply.getInvoiceNo() != null && !emisWriteoffApply.getInvoiceNo().trim().isEmpty()) {
|
||||
emisWriteoffApply.setInvoiceNo(
|
||||
com.xdadan.erp.emis.utils.WaybillHelper.formatQueryValue(emisWriteoffApply.getInvoiceNo()));
|
||||
}
|
||||
|
||||
// 处理params参数,支持运单号、账单号多选查询
|
||||
if (emisWriteoffApply.getParams() != null && emisWriteoffApply.getParams().containsKey("queryParams")) {
|
||||
String queryParams = (String) emisWriteoffApply.getParams().get("queryParams");
|
||||
@ -86,6 +96,49 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
|
||||
// 计算并设置申请账单相关字段
|
||||
if (list != null) {
|
||||
// 收集所有运单号,用于一次性查询对应的发票号
|
||||
java.util.Set<String> allBillCodes = new java.util.HashSet<>();
|
||||
|
||||
for (EmisWriteoffApply apply : list) {
|
||||
if (apply != null && apply.getDetailList() != null && !apply.getDetailList().isEmpty()) {
|
||||
for (EmisWriteoffApplyDetail detail : apply.getDetailList()) {
|
||||
if (detail != null && detail.getBillCode() != null && !detail.getBillCode().trim().isEmpty()) {
|
||||
allBillCodes.add(detail.getBillCode().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询所有相关运单号对应的发票记录,并构造 billCode -> 发票号列表 映射
|
||||
java.util.Map<String, java.util.List<String>> billInvoiceMap = new java.util.HashMap<>();
|
||||
if (!allBillCodes.isEmpty()) {
|
||||
java.util.List<String> billCodeList = new java.util.ArrayList<>(allBillCodes);
|
||||
java.util.List<com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord> invoiceRecords =
|
||||
emisSettleInvoiceRecordService.selectInvoiceRecordListByBillCodes(billCodeList);
|
||||
if (invoiceRecords != null) {
|
||||
for (com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord record : invoiceRecords) {
|
||||
if (record == null || record.getInvoiceNo() == null
|
||||
|| record.getInvoiceNo().trim().isEmpty()
|
||||
|| record.getBillCodes() == null
|
||||
|| record.getBillCodes().trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String[] codes = record.getBillCodes().split(",");
|
||||
for (String code : codes) {
|
||||
if (code == null) {
|
||||
continue;
|
||||
}
|
||||
String billCode = code.trim();
|
||||
if (billCode.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
billInvoiceMap.computeIfAbsent(billCode, k -> new java.util.ArrayList<>())
|
||||
.add(record.getInvoiceNo().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (EmisWriteoffApply apply : list) {
|
||||
if (apply != null && apply.getDetailList() != null && !apply.getDetailList().isEmpty()) {
|
||||
// 提取账单名称列表(去重)
|
||||
@ -124,6 +177,23 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
})
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
apply.setApplyRecMoney(totalAmount);
|
||||
|
||||
// 计算并设置发票号列表(去重后用逗号拼接)
|
||||
java.util.Set<String> invoiceNos = new java.util.LinkedHashSet<>();
|
||||
for (EmisWriteoffApplyDetail detail : apply.getDetailList()) {
|
||||
if (detail == null || detail.getBillCode() == null) {
|
||||
continue;
|
||||
}
|
||||
java.util.List<String> invList = billInvoiceMap.get(detail.getBillCode().trim());
|
||||
if (invList != null) {
|
||||
for (String inv : invList) {
|
||||
if (inv != null && !inv.trim().isEmpty()) {
|
||||
invoiceNos.add(inv.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
apply.setInvoiceNo(invoiceNos.isEmpty() ? "" : String.join(",", invoiceNos));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,6 +212,12 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
emisWriteoffApply = new EmisWriteoffApply();
|
||||
}
|
||||
|
||||
// 支持按发票号查询:将多行发票号格式化为逗号分隔
|
||||
if (emisWriteoffApply.getInvoiceNo() != null && !emisWriteoffApply.getInvoiceNo().trim().isEmpty()) {
|
||||
emisWriteoffApply.setInvoiceNo(
|
||||
com.xdadan.erp.emis.utils.WaybillHelper.formatQueryValue(emisWriteoffApply.getInvoiceNo()));
|
||||
}
|
||||
|
||||
// 处理params参数,支持运单号、账单号多选查询
|
||||
if (emisWriteoffApply.getParams() != null && emisWriteoffApply.getParams().containsKey("queryParams")) {
|
||||
String queryParams = (String) emisWriteoffApply.getParams().get("queryParams");
|
||||
@ -508,8 +584,57 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
// 获取当前登录用户信息
|
||||
String currentEmpName = getLoginUser().getUser().getEmpName();
|
||||
|
||||
// 验证权限和账单状态
|
||||
// 先为返回的明细填充发票号信息(每个运单可能存在多张发票,逗号分隔)
|
||||
java.util.Set<String> allBillCodes = list.stream()
|
||||
.filter(d -> d != null && d.getBillCode() != null && !d.getBillCode().trim().isEmpty())
|
||||
.map(d -> d.getBillCode().trim())
|
||||
.collect(java.util.stream.Collectors.toSet());
|
||||
|
||||
java.util.Map<String, String> billInvoiceStrMap = new java.util.HashMap<>();
|
||||
if (!allBillCodes.isEmpty()) {
|
||||
java.util.List<String> billCodeListAll = new java.util.ArrayList<>(allBillCodes);
|
||||
java.util.List<com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord> invoiceRecords =
|
||||
emisSettleInvoiceRecordService.selectInvoiceRecordListByBillCodes(billCodeListAll);
|
||||
if (invoiceRecords != null) {
|
||||
java.util.Map<String, java.util.Set<String>> billInvoiceSetMap = new java.util.HashMap<>();
|
||||
for (com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord record : invoiceRecords) {
|
||||
if (record == null || record.getInvoiceNo() == null
|
||||
|| record.getInvoiceNo().trim().isEmpty()
|
||||
|| record.getBillCodes() == null
|
||||
|| record.getBillCodes().trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String invoiceNo = record.getInvoiceNo().trim();
|
||||
String[] codes = record.getBillCodes().split(",");
|
||||
for (String code : codes) {
|
||||
if (code == null) {
|
||||
continue;
|
||||
}
|
||||
String billCode = code.trim();
|
||||
if (billCode.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
billInvoiceSetMap.computeIfAbsent(billCode, k -> new java.util.LinkedHashSet<>())
|
||||
.add(invoiceNo);
|
||||
}
|
||||
}
|
||||
// 转换为逗号分隔的字符串
|
||||
for (java.util.Map.Entry<String, java.util.Set<String>> entry : billInvoiceSetMap.entrySet()) {
|
||||
billInvoiceStrMap.put(entry.getKey(),
|
||||
String.join(",", entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 验证权限和账单状态,并设置每条明细的发票号
|
||||
for (EmisWriteoffApplyDetail detail : list) {
|
||||
if (detail != null && detail.getBillCode() != null) {
|
||||
String invoiceStr = billInvoiceStrMap.get(detail.getBillCode().trim());
|
||||
if (invoiceStr != null) {
|
||||
detail.setInvoiceNo(invoiceStr);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 验证用户权限:检查是否是运单的销售联系人/回款联系人/销售联系人关联的助理
|
||||
if (!hasPermissionToViewBill(detail, currentEmpName)) {
|
||||
return error("您没有权限查看运单 " + detail.getBillCode() + " 的信息");
|
||||
|
||||
@ -80,6 +80,9 @@ public class EmisWriteoffApply extends BaseEntity {
|
||||
/* 收款来源 1-微信支付2支付宝 3-对公 */
|
||||
private String payType;
|
||||
|
||||
/* 发票号 */
|
||||
private String invoiceNo;
|
||||
|
||||
/* 交易时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date tradeDate;
|
||||
|
||||
@ -72,4 +72,6 @@ public class EmisWriteoffApplyDetail extends BaseEntity {
|
||||
@Excel(name = "快件类型")
|
||||
private String expressType;
|
||||
|
||||
/* 发票号(只作查询) */
|
||||
private String invoiceNo;
|
||||
}
|
||||
|
||||
@ -45,19 +45,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmisWriteoffApplyVo">
|
||||
select id, apply_no, apply_man_code, apply_man_name, apply_site_code, apply_site_name, apply_date, writeoff_amount, pay_type, trade_date, recipient, apply_memo, pay_id, bl_center_confirmed, center_confirm_man_code, center_confirm_man_name, center_confirm_date, center_confirm_note, center_reject_reason, bl_headquarters_confirmed, headquarters_confirm_man_code, headquarters_confirm_man_name, headquarters_confirm_date, headquarters_confirm_note, headquarters_reject_reason, revoke_date, revoke_man_code, revoke_man_name, revoke_reason, del_flag, create_by, create_time, update_by, update_time, remark from emis_writeoff_apply
|
||||
select id,
|
||||
apply_no,
|
||||
apply_man_code,
|
||||
apply_man_name,
|
||||
apply_site_code,
|
||||
apply_site_name,
|
||||
apply_date,
|
||||
writeoff_amount,
|
||||
pay_type,
|
||||
trade_date,
|
||||
recipient,
|
||||
apply_memo,
|
||||
pay_id,
|
||||
bl_center_confirmed,
|
||||
center_confirm_man_code,
|
||||
center_confirm_man_name,
|
||||
center_confirm_date,
|
||||
center_confirm_note,
|
||||
center_reject_reason,
|
||||
bl_headquarters_confirmed,
|
||||
headquarters_confirm_man_code,
|
||||
headquarters_confirm_man_name,
|
||||
headquarters_confirm_date,
|
||||
headquarters_confirm_note,
|
||||
headquarters_reject_reason,
|
||||
revoke_date,
|
||||
revoke_man_code,
|
||||
revoke_man_name,
|
||||
revoke_reason,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark
|
||||
from emis_writeoff_apply
|
||||
</sql>
|
||||
|
||||
<select id="selectEmisWriteoffApplyList" parameterType="EmisWriteoffApply" resultMap="EmisWriteoffApplyResult">
|
||||
select distinct wa.id, wa.apply_no, wa.apply_man_code, wa.apply_man_name, wa.apply_site_code, wa.apply_site_name,
|
||||
wa.apply_date, wa.writeoff_amount, wa.pay_type, wa.trade_date, wa.recipient, wa.apply_memo, wa.pay_id,
|
||||
select distinct wa.id,
|
||||
wa.apply_no,
|
||||
wa.apply_man_code,
|
||||
wa.apply_man_name,
|
||||
wa.apply_site_code,
|
||||
wa.apply_site_name,
|
||||
wa.apply_date,
|
||||
wa.writeoff_amount,
|
||||
wa.pay_type,
|
||||
wa.trade_date,
|
||||
wa.recipient,
|
||||
wa.apply_memo,
|
||||
wa.pay_id,
|
||||
wa.bl_center_confirmed, wa.center_confirm_man_code, wa.center_confirm_man_name, wa.center_confirm_date,
|
||||
wa.center_confirm_note, wa.center_reject_reason, wa.bl_headquarters_confirmed, wa.headquarters_confirm_man_code,
|
||||
wa.headquarters_confirm_man_name, wa.headquarters_confirm_date, wa.headquarters_confirm_note,
|
||||
wa.headquarters_reject_reason, wa.revoke_date, wa.revoke_man_code, wa.revoke_man_name, wa.revoke_reason,
|
||||
wa.del_flag, wa.create_by, wa.create_time, wa.update_by, wa.update_time, wa.remark
|
||||
from emis_writeoff_apply wa
|
||||
<if test="(params != null and params.queryParams != null and params.queryParams != '') or (settleBillName != null and settleBillName != '')">
|
||||
<if test="(params != null and params.queryParams != null and params.queryParams != '') or (settleBillName != null and settleBillName != '') or (invoiceNo != null and invoiceNo != '')">
|
||||
left join emis_writeoff_apply_detail wad on wa.id = wad.apply_id and wad.del_flag = '0'
|
||||
</if>
|
||||
<if test="settleBillName != null and settleBillName != ''">
|
||||
@ -74,6 +120,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="applyDateStart != null "> and wa.apply_date >= #{applyDateStart}</if>
|
||||
<if test="applyDateEnd != null "> and wa.apply_date <= #{applyDateEnd}</if>
|
||||
<if test="writeoffAmount != null "> and wa.writeoff_amount = #{writeoffAmount}</if>
|
||||
<if test="payType != null and payType != ''"> and wa.pay_type = #{payType}</if>
|
||||
<if test="invoiceNo != null and invoiceNo != ''">
|
||||
and exists (
|
||||
select 1
|
||||
from emis_settle_invoice_record a
|
||||
left join (
|
||||
select ch1.*
|
||||
from emis_settle_invoice_ch_record ch1
|
||||
inner join (
|
||||
select apply_seq_no, max(id) as max_id
|
||||
from emis_settle_invoice_ch_record
|
||||
where del_flag = '0'
|
||||
group by apply_seq_no
|
||||
) ch2 on ch1.apply_seq_no = ch2.apply_seq_no and ch1.id = ch2.max_id
|
||||
where ch1.del_flag = '0'
|
||||
) ch on a.apply_seq_no = ch.apply_seq_no
|
||||
inner join emis_settle_invoice_rel rel on rel.apply_seq_no = a.apply_seq_no and rel.del_flag = '0'
|
||||
where a.del_flag = '0'
|
||||
and FIND_IN_SET(ch.invoice_no, REPLACE(#{invoiceNo}, '\n', ','))
|
||||
and rel.bill_no = wad.bill_code
|
||||
)
|
||||
</if>
|
||||
<if test="applyMemo != null and applyMemo != ''"> and wa.apply_memo like concat('%', #{applyMemo}, '%')</if>
|
||||
<if test="blCenterConfirmed != null and blCenterConfirmed != ''"> and wa.bl_center_confirmed = #{blCenterConfirmed}</if>
|
||||
<if test="centerConfirmManCode != null and centerConfirmManCode != ''"> and wa.center_confirm_man_code = #{centerConfirmManCode}</if>
|
||||
@ -223,6 +291,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="applySiteName != null and applySiteName != ''">apply_site_name = #{applySiteName},</if>
|
||||
<if test="applyDate != null">apply_date = #{applyDate},</if>
|
||||
<if test="writeoffAmount != null">writeoff_amount = #{writeoffAmount},</if>
|
||||
<if test="payType != null and payType != ''">pay_type = #{payType},</if>
|
||||
<if test="applyMemo != null and applyMemo != ''">apply_memo = #{applyMemo},</if>
|
||||
<if test="payId != null and payId != ''">pay_id = #{payId},</if>
|
||||
<if test="blCenterConfirmed != null and blCenterConfirmed != ''">bl_center_confirmed = #{blCenterConfirmed},</if>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user