fix: align task hall export with selected month and full receiver dept list

This commit is contained in:
Your Name 2026-02-24 16:38:43 +08:00
parent 5dbbec8ac9
commit 34ead8be3d
4 changed files with 35 additions and 10 deletions

View File

@ -39,6 +39,7 @@ public class ExportController {
HttpServletRequest request,
HttpServletResponse response,
@Parameter(description = "任务状态") @RequestParam(required = false) String status,
@Parameter(description = "月份,格式:YYYY-MM") @RequestParam(required = false) String month,
@Parameter(description = "发布部门ID") @RequestParam(required = false) Long publisherDeptId,
@Parameter(description = "接收部门ID") @RequestParam(required = false) Long receiverDeptId,
@Parameter(description = "品牌ID") @RequestParam(required = false) Long brandId,
@ -68,7 +69,7 @@ public class ExportController {
log.info("用户 {} ({}) 导出任务大厅数据, isAdmin={}, isDeptLeader={}",
user.getRealName(), userId, isAdmin, isDeptLeader);
exportService.exportTaskHall(response, status, publisherDeptId, receiverDeptId, brandId, categoryId, platformId);
exportService.exportTaskHall(response, status, month, publisherDeptId, receiverDeptId, brandId, categoryId, platformId);
}
@Operation(summary = "导出任务列表")
@ -103,4 +104,3 @@ public class ExportController {
exportService.exportDesignerStats(response);
}
}

View File

@ -11,7 +11,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
@ -46,16 +48,32 @@ public class ExportService {
* 🔥 修复:按子任务行导出,与前端任务大厅显示一致
* 前端显示的是每个可接单的子任务,导出也应该按子任务行导出
*/
public void exportTaskHall(HttpServletResponse response, String status, Long publisherDeptId,
public void exportTaskHall(HttpServletResponse response, String status, String month, Long publisherDeptId,
Long receiverDeptId, Long brandId, Long categoryId, Long platformId) throws IOException {
log.info("开始导出任务大厅数据: status={}, publisherDeptId={}, receiverDeptId={}, brandId={}, categoryId={}, platformId={}",
status, publisherDeptId, receiverDeptId, brandId, categoryId, platformId);
String effectiveStatus = (status != null && !status.isEmpty()) ? status : "pending";
log.info("开始导出任务大厅数据: status={}, month={}, publisherDeptId={}, receiverDeptId={}, brandId={}, categoryId={}, platformId={}",
status, month, publisherDeptId, receiverDeptId, brandId, categoryId, platformId);
LocalDateTime monthStart = null;
LocalDateTime monthEnd = null;
if (month != null && !month.isBlank()) {
try {
LocalDate targetMonth = LocalDate.parse(month + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
monthStart = LocalDateTime.of(targetMonth, LocalTime.MIN);
monthEnd = monthStart.plusMonths(1).minusSeconds(1);
} catch (Exception e) {
log.warn("导出任务大厅数据月份格式错误: {}", month);
}
}
// 🔥 查询可接单的子任务(这是前端任务大厅实际显示的数据)
LambdaQueryWrapper<TaskItem> itemQueryWrapper = new LambdaQueryWrapper<>();
itemQueryWrapper.eq(TaskItem::getStatus, effectiveStatus);
if (status != null && !status.isBlank() && !"all".equalsIgnoreCase(status)) {
itemQueryWrapper.eq(TaskItem::getStatus, status);
}
if (monthStart != null && monthEnd != null) {
itemQueryWrapper.ge(TaskItem::getCreateTime, monthStart)
.le(TaskItem::getCreateTime, monthEnd);
}
if (receiverDeptId != null) {
itemQueryWrapper.eq(TaskItem::getReceiverDeptId, receiverDeptId);
}
@ -150,7 +168,11 @@ public class ExportService {
taskItemsMap.put(virtualId, List.of(correspondingItem));
virtualTaskToItemMap.put(virtualId, correspondingItem);
}
Map<Long, String> taskActualReceiverDeptListMap = buildTaskActualReceiverDeptListMap(filteredItems, deptMap);
List<TaskItem> allTaskItems = taskIds.isEmpty() ? List.of() : taskItemMapper.selectList(
new LambdaQueryWrapper<TaskItem>()
.in(TaskItem::getTaskId, taskIds)
);
Map<Long, String> taskActualReceiverDeptListMap = buildTaskActualReceiverDeptListMap(allTaskItems, deptMap);
// 🔥 第一遍遍历:收集所有出现的任务类型名称(用于动态列)
java.util.LinkedHashSet<String> allTypeNames = new java.util.LinkedHashSet<>();

View File

@ -721,6 +721,7 @@ export const deleteTaskByTaskNo = (taskNo: string) => {
*/
export interface ExportTaskHallParams {
status?: string
month?: string
publisherDeptId?: number
receiverDeptId?: number
brandId?: number
@ -731,6 +732,7 @@ export interface ExportTaskHallParams {
export const exportTaskHall = async (params: ExportTaskHallParams = {}) => {
const queryParams = new URLSearchParams()
if (params.status) queryParams.append('status', params.status)
if (params.month) queryParams.append('month', params.month)
if (params.publisherDeptId) queryParams.append('publisherDeptId', params.publisherDeptId.toString())
if (params.receiverDeptId) queryParams.append('receiverDeptId', params.receiverDeptId.toString())
if (params.brandId) queryParams.append('brandId', params.brandId.toString())

View File

@ -4745,7 +4745,8 @@ const handleExportTaskHall = async () => {
// 构建导出参数(使用当前筛选条件)
const params: ExportTaskHallParams = {
status: filters.status || 'pending',
status: filters.status || undefined,
month: selectedMonth.value ? selectedMonth.value.format('YYYY-MM') : undefined,
brandId: filters.brandId,
categoryId: filters.categoryId,
platformId: filters.platformId