✨ 毛利分析订单支持异步导出

This commit is contained in:
caojia
2026-11-17 14:55:54 +08:00
parent e104c5a3e9
commit d8f6ceda59
8 changed files with 576 additions and 26 deletions
@@ -8,6 +8,7 @@ import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import com.github.pagehelper.PageHelper;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.bms.common.annotation.Log;
@@ -39,6 +41,7 @@ import com.bms.price.domain.vo.PrcProfitReportProductRow;
import com.bms.price.domain.vo.PrcProfitReportQuery;
import com.bms.price.domain.vo.PrcProfitReportSummary;
import com.bms.price.service.IPrcProfitReportService;
import com.bms.price.task.PrcProfitReportExportRunner;
/** 产品/订单维度毛利报表。 */
@RestController
@@ -51,6 +54,9 @@ public class PrcProfitReportController extends BaseController
@Autowired
private OssStorage ossStorage;
@Autowired
private PrcProfitReportExportRunner exportRunner;
/** 客户筛选选项,沿用毛利报表的访问权限和查询范围。 */
@PreAuthorize("@ss.hasPermi('report:profit:list')")
@GetMapping("/customer-options")
@@ -124,19 +130,23 @@ public class PrcProfitReportController extends BaseController
@Log(title = "毛利报表-订单维度", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('report:profit:export')")
@PostMapping("/orders/export")
public AjaxResult exportOrders(PrcProfitReportQuery query)
public AjaxResult exportOrders(@RequestBody PrcProfitReportQuery query)
{
PrcProfitReportExport export = beginExport("ORDER", "订单维度毛利分析");
try
{
List<PrcProfitReportOrderRow> rows = profitReportService.selectOrderRows(query);
return finishExport(export, rows, PrcProfitReportOrderRow.class, "订单毛利报表", query.getProfitRule());
}
catch (RuntimeException e)
{
failExport(export, e);
throw e;
}
return success(Map.of("taskId", exportRunner.submit(query, getUserId())));
}
@PreAuthorize("@ss.hasPermi('report:profit:export')")
@GetMapping("/orders/export/task/{taskId}")
public AjaxResult orderExportTask(@PathVariable String taskId)
{
return success(exportRunner.getTask(taskId, getUserId()));
}
@PreAuthorize("@ss.hasPermi('report:profit:export')")
@GetMapping("/orders/export/download/{taskId}")
public void downloadOrderExport(@PathVariable String taskId, HttpServletResponse response) throws Exception
{
exportRunner.download(taskId, getUserId(), response);
}
@Log(title = "毛利报表-产品维度", businessType = BusinessType.EXPORT)