This commit is contained in:
wuweihua
2026-11-12 16:53:45 +08:00
7 changed files with 188 additions and 24 deletions
@@ -1,6 +1,7 @@
package com.bms.receivable.task;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
@@ -75,10 +76,18 @@ public class ArBillGeneratePreviewExportRunner {
put(taskId, userId, "RUNNING", 5, "正在查询订单", null, 0, fileName, null);
List<PrcOrderBill> bills = billService.previewBill(query, scope);
put(taskId, userId, "RUNNING", 40, "正在生成 Excel", null, bills.size(), fileName, null);
List<ArBillGeneratePreviewExportRow> rows = new ArrayList<>(bills.size());
List<ArBillGeneratePreviewExportRow> rows = new ArrayList<>(bills.size() + 1);
BigDecimal totalAmount = BigDecimal.ZERO;
for (PrcOrderBill bill : bills) {
rows.add(ArBillGeneratePreviewExportRow.from(bill));
if (bill.getIncomeTotal() != null) {
totalAmount = totalAmount.add(bill.getIncomeTotal());
}
}
ArBillGeneratePreviewExportRow totalRow = new ArBillGeneratePreviewExportRow();
totalRow.setOrderNo("合计");
totalRow.setIncomeTotal(totalAmount);
rows.add(totalRow);
ExcelUtil<ArBillGeneratePreviewExportRow> util = new ExcelUtil<>(ArBillGeneratePreviewExportRow.class);
if (ArBillDateType.PICKUP_DATE == ArBillDateType.of(query.getDateType())) {
util.hideColumn("bizDate");
@@ -694,14 +694,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{excludedBillId}
</foreach>
</if>
<choose>
<when test="dateType != null and dateType == 'PICKUP_DATE'">
order by p.pickup_date, p.order_no, p.bill_id
</when>
<otherwise>
order by p.biz_date, p.order_no, p.bill_id
</otherwise>
</choose>
order by p.bill_id
</select>
<select id="sumPrcOrderBillIncomeByCustomerPeriod" resultType="java.math.BigDecimal">
@@ -11,20 +11,27 @@
AND bill_id IN
<foreach collection="sourceIds" item="sourceId" open="(" separator="," close=")">#{sourceId}</foreach>
</select>
<!-- c 固定为客户表别名;无部门层级扩展,不按角色管理 data_scope 过滤。 -->
<!-- c 固定为客户表别名;销售经理可见本部门及下级部门,不按角色管理 data_scope 过滤。 -->
<sql id="customerScope">
<choose>
<when test="scope != null and scope.all"/>
<when test="scope != null and (scope.self or scope.department)">
AND c.del_flag = '0'
AND EXISTS (
SELECT 1 FROM sys_user su
WHERE CAST(su.user_id AS CHAR) = c.sales_user_id AND su.del_flag = '0'
AND (1 = 0
<if test="scope.self">OR su.user_id = #{scope.userId}</if>
<if test="scope.department">OR su.dept_id = #{scope.deptId}</if>
SELECT 1 FROM sys_user su
WHERE CAST(su.user_id AS CHAR) = c.sales_user_id AND su.del_flag = '0'
AND (1 = 0
<if test="scope.self">OR su.user_id = #{scope.userId}</if>
<if test="scope.department">
OR EXISTS (
SELECT 1 FROM sys_dept dept
WHERE dept.dept_id = su.dept_id
AND (dept.dept_id = #{scope.deptId}
OR find_in_set(#{scope.deptId}, dept.ancestors))
)
</if>
)
)
)
</when>
<otherwise>AND 1 = 0</otherwise>
</choose>