打印数据

This commit is contained in:
2026-04-16 14:38:14 +08:00
parent 710cca65d6
commit cef7e5315a
27 changed files with 467 additions and 86 deletions

View File

@@ -1,7 +1,6 @@
package com.czg.controller.admin;
import com.czg.excel.ExcelExportUtil;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopProdStatistic;
import com.czg.order.param.SaleSummaryCountParam;
import com.czg.order.service.ShopProdStatisticService;
@@ -36,7 +35,6 @@ public class SaleSummaryController {
* 统计
*/
@GetMapping("count")
@OperationLog("统计")
//@SaAdminCheckPermission("saleSummary:count")
public CzgResult<SaleSummaryCountVo> summaryCount(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
@@ -50,7 +48,6 @@ public class SaleSummaryController {
* 分页
*/
@GetMapping("page")
@OperationLog("分页")
//@SaAdminCheckPermission("saleSummary:page")
public CzgResult<List<ShopProdStatistic>> summaryPage(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
@@ -60,6 +57,9 @@ public class SaleSummaryController {
return CzgResult.success(list);
}
/**
* 商品报表导出
*/
@GetMapping("/export")
public void summaryExport(SaleSummaryCountParam param, HttpServletResponse response) {
if (param.getShopId() == null) {
@@ -68,4 +68,15 @@ public class SaleSummaryController {
ExcelExportUtil.exportToResponse(prodStatisticService.getArchiveTradeData(param), ShopProdStatistic.class, "销售统计明细", response);
}
/**
* 商品报表打印
*/
@GetMapping("/print")
public void summaryPrint(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
prodStatisticService.summaryPrint(param);
}
}

View File

@@ -0,0 +1,36 @@
package com.czg.controller.admin;
import com.czg.order.entity.SysPrintData;
import com.czg.order.service.SysPrintDataService;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 打印数据
*
* @author ww
*/
@RestController
@RequestMapping("/admin/printData")
public class SysPrintDataController {
@Resource
private SysPrintDataService sysPrintDataService;
/**
* 获取打印数据
*/
@GetMapping
public CzgResult<SysPrintData> getWareCount(@RequestParam Long shopId, @RequestParam Long dataId, @RequestParam String type) {
return CzgResult.success(sysPrintDataService.getOne(new QueryWrapper()
.eq(SysPrintData::getType, type)
.eq(SysPrintData::getShopId, shopId)
.eq(SysPrintData::getId, dataId)));
}
}

View File

@@ -3,9 +3,12 @@ package com.czg.mq;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.config.RabbitConstants;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.order.entity.MqLog;
import com.czg.order.entity.SysPrintData;
import com.czg.order.service.MqLogService;
import com.czg.order.service.SysPrintDataService;
import com.czg.service.RedisService;
import com.czg.service.order.print.PrintConfig;
import com.czg.service.order.print.PrinterHandler;
@@ -30,6 +33,10 @@ public class PrintMqListener {
private RedisService redisService;
@Resource
private PrintConfig printConfig;
@Resource
private RabbitPublisher rabbitPublisher;
@Resource
protected SysPrintDataService printDataService;
private <T> void invokeFun(String queue, String type, String plat, T data, Consumer<T> consumer) {
long startTime = DateUtil.date().getTime();
@@ -74,6 +81,11 @@ public class PrintMqListener {
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE})
public void otherPrint(Long shopId, Object o, String printTypeEnum) {
PrinterHandler.PrintTypeEnum typeEnum = PrinterHandler.PrintTypeEnum.valueOf(printTypeEnum);
SysPrintData sysPrintData = new SysPrintData();
sysPrintData.setShopId(shopId);
sysPrintData.setData(JSONObject.toJSONString(o));
printDataService.save(sysPrintData);
rabbitPublisher.sendOtherPrintLocalMsg(shopId, printTypeEnum, sysPrintData.getId());
printConfig.otherHandler(shopId, o, typeEnum);
}
}