打印
This commit is contained in:
@@ -198,27 +198,33 @@ public class PrintConfig implements ApplicationRunner {
|
|||||||
.stockPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(data.toJSONString(), StockPrintDTO.class)));
|
.stockPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(data.toJSONString(), StockPrintDTO.class)));
|
||||||
break;
|
break;
|
||||||
case PrinterHandler.PrintTypeEnum.DAY_REPORT:
|
case PrinterHandler.PrintTypeEnum.DAY_REPORT:
|
||||||
Map<String, DayReportPrintDTO> map1 = data.to(new TypeReference<>() {
|
List<Map<String, Object>> list = data.to(new TypeReference<>() {
|
||||||
});
|
});
|
||||||
for (PrintMachine machine : getPrintMachine(shopId, printTypeEnum)) {
|
for (PrintMachine machine : getPrintMachine(shopId, printTypeEnum)) {
|
||||||
PrinterHandler printer = getPrinter(machine.getBrand());
|
PrinterHandler printer = getPrinter(machine.getBrand());
|
||||||
map1.forEach((day, value) -> printer.dayReportPrint(machine, shopInfo.getShopName(), value));
|
for (Map<String, Object> map : list) {
|
||||||
|
printer.dayReportPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(map.get("data").toString(), DayReportPrintDTO.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PrinterHandler.PrintTypeEnum.DAY_ORDER:
|
case PrinterHandler.PrintTypeEnum.DAY_ORDER:
|
||||||
Map<String, DaySettlePrintDTO> map2 = data.to(new TypeReference<>() {
|
List<Map<String, Object>> list2 = data.to(new TypeReference<>() {
|
||||||
});
|
});
|
||||||
for (PrintMachine machine : getPrintMachine(shopId, printTypeEnum)) {
|
for (PrintMachine machine : getPrintMachine(shopId, printTypeEnum)) {
|
||||||
PrinterHandler printer = getPrinter(machine.getBrand());
|
PrinterHandler printer = getPrinter(machine.getBrand());
|
||||||
map2.forEach((day, value) -> printer.daySettlePrint(machine, shopInfo.getShopName(), value));
|
for (Map<String, Object> map : list2) {
|
||||||
|
printer.daySettlePrint(machine, shopInfo.getShopName(), JSONObject.parseObject(map.get("data").toString(), DaySettlePrintDTO.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PrinterHandler.PrintTypeEnum.PRODUCT_REPORT:
|
case PrinterHandler.PrintTypeEnum.PRODUCT_REPORT:
|
||||||
Map<String, ProductReportPrintDTO> map3 = data.to(new TypeReference<>() {
|
List<Map<String, Object>> list3 = data.to(new TypeReference<>() {
|
||||||
});
|
});
|
||||||
for (PrintMachine machine : getPrintMachine(shopId, printTypeEnum)) {
|
for (PrintMachine machine : getPrintMachine(shopId, printTypeEnum)) {
|
||||||
PrinterHandler printer = getPrinter(machine.getBrand());
|
PrinterHandler printer = getPrinter(machine.getBrand());
|
||||||
map3.forEach((day, value) -> printer.productReportPrint(machine, shopInfo.getShopName(), value));
|
for (Map<String, Object> map : list3) {//ProductReportPrintDTO
|
||||||
|
printer.productReportPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(map.get("data").toString(), ProductReportPrintDTO.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PrinterHandler.PrintTypeEnum.RECHARGE:
|
case PrinterHandler.PrintTypeEnum.RECHARGE:
|
||||||
|
|||||||
@@ -653,9 +653,8 @@ public interface PrinterImpl {
|
|||||||
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
PrintSignLabel signLabelInfo = getSignLabelInfo();
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
// 标题:店铺名称 + 经营日报(居中,和充值/入库单风格统一)
|
|
||||||
builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
builder.append(formatLabel(record.getShopName(), signLabelInfo.center)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel("经营日报", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br);
|
builder.append(formatLabel("日结单", signLabelInfo.center)).append(signLabelInfo.br).append(signLabelInfo.br);
|
||||||
|
|
||||||
// 基础信息:打印时间、操作人、统计时间
|
// 基础信息:打印时间、操作人、统计时间
|
||||||
builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(StrUtil.format("打印时间: {}", DateUtil.format(LocalDateTime.now(), "yyyy/MM/dd HH:mm:ss")), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
@@ -668,8 +667,8 @@ public interface PrinterImpl {
|
|||||||
builder.append(formatLabel(LRAlign(" 订单原价总额", bdToStr(turnover.getOriginAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(LRAlign(" 订单原价总额", bdToStr(turnover.getOriginAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel(LRAlign(" 营业额", bdToStr(turnover.getTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(LRAlign(" 营业额", bdToStr(turnover.getTurnover()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel(LRAlign(" 优惠金额", bdToStr(turnover.getDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(LRAlign(" 优惠金额", bdToStr(turnover.getDiscountAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel(LRAlign(" 订单数(含退款)", String.valueOf(turnover.getOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(LRAlign(" 订单数(含退款)", turnover.getOrderCount() == null ? "0" : String.valueOf(turnover.getOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel(LRAlign(" 退款订单数", String.valueOf(turnover.getRefundOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(LRAlign(" 退款订单数", turnover.getRefundOrderCount() == null ? "0" : String.valueOf(turnover.getRefundOrderCount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel(LRAlign(" 退款金额", bdToStr(turnover.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(LRAlign(" 退款金额", bdToStr(turnover.getRefundAmount()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel(LRAlign(" 现金收款", bdToStr(turnover.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(LRAlign(" 现金收款", bdToStr(turnover.getCash()), 32), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
builder.append(formatLabel(" 备用金", signLabelInfo.s)).append(signLabelInfo.br);
|
builder.append(formatLabel(" 备用金", signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
@@ -701,7 +700,7 @@ public interface PrinterImpl {
|
|||||||
builder.append(formatLabel("敏感操作记录", signLabelInfo.bold)).append(signLabelInfo.br);
|
builder.append(formatLabel("敏感操作记录", signLabelInfo.bold)).append(signLabelInfo.br);
|
||||||
for (DaySettlePrintDTO.OperationRecord operation : operationRecords) {
|
for (DaySettlePrintDTO.OperationRecord operation : operationRecords) {
|
||||||
builder.append(formatLabel(
|
builder.append(formatLabel(
|
||||||
key3(operation.getOperation(), "数量:" + operation.getCount(), "金额" + operation.getAmount(), 8, 14)
|
key3(operation.getOperation(), "数量:" + operation.getCount(), "金额" + bdToStr(operation.getAmount()), 8, 14)
|
||||||
, signLabelInfo.s)).append(signLabelInfo.br);
|
, signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,27 +111,28 @@ public class FinanceStsServiceImpl implements FinanceStsService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printDayReport(SaleSummaryCountParam param) {
|
public void printDayReport(SaleSummaryCountParam param) {
|
||||||
Map<String, DayReportPrintDTO> dayReportMap = buildDayReportPrint(param);
|
List<Map<String, Object>> list = buildDayReportPrint(param);
|
||||||
if (CollUtil.isEmpty(dayReportMap)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
throw new CzgException("无可打印数据");
|
throw new CzgException("无可打印数据");
|
||||||
}
|
}
|
||||||
// 打印经营日报
|
// 打印经营日报
|
||||||
rabbitPublisher.sendOtherPrintMsg(param.getShopId(), dayReportMap, "DAY_REPORT");
|
rabbitPublisher.sendOtherPrintMsg(param.getShopId(), list, "DAY_REPORT");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printDaySettle(SaleSummaryCountParam param) {
|
public void printDaySettle(SaleSummaryCountParam param) {
|
||||||
Map<String, DaySettlePrintDTO> daySettleMap = buildDaySettlePrint(param);
|
List<Map<String, Object>> daySettleList = buildDaySettlePrint(param);
|
||||||
if (CollUtil.isEmpty(daySettleMap)) {
|
if (CollUtil.isEmpty(daySettleList)) {
|
||||||
throw new CzgException("无可打印数据");
|
throw new CzgException("无可打印数据");
|
||||||
}
|
}
|
||||||
// 打印日结单
|
// 打印日结单
|
||||||
rabbitPublisher.sendOtherPrintMsg(param.getShopId(), daySettleMap, "DAY_ORDER");
|
rabbitPublisher.sendOtherPrintMsg(param.getShopId(), daySettleList, "DAY_ORDER");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, DayReportPrintDTO> buildDayReportPrint(SaleSummaryCountParam param) {
|
private List<Map<String, Object>> buildDayReportPrint(SaleSummaryCountParam param) {
|
||||||
Map<String, DayReportPrintDTO> dayReportMap = new HashMap<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
Map<String, Object> dayReportMap = new HashMap<>();
|
||||||
if (param.getBeginDate() != null && param.getEndDate() != null) {
|
if (param.getBeginDate() != null && param.getEndDate() != null) {
|
||||||
// 计算相差天数
|
// 计算相差天数
|
||||||
long days = java.time.temporal.ChronoUnit.DAYS.between(param.getBeginDate(), param.getEndDate());
|
long days = java.time.temporal.ChronoUnit.DAYS.between(param.getBeginDate(), param.getEndDate());
|
||||||
@@ -206,15 +207,18 @@ public class FinanceStsServiceImpl implements FinanceStsService {
|
|||||||
discountSts.setOrderDiscount(statisticData.getOrderPriceDiscountAmount()); // 订单改价
|
discountSts.setOrderDiscount(statisticData.getOrderPriceDiscountAmount()); // 订单改价
|
||||||
dayReportPrintDTO.setDiscountSta(discountSts);
|
dayReportPrintDTO.setDiscountSta(discountSts);
|
||||||
// 加入结果集
|
// 加入结果集
|
||||||
dayReportMap.put(localDate.toString(), dayReportPrintDTO);
|
dayReportMap.put("date", localDate);
|
||||||
|
dayReportMap.put("data", dayReportPrintDTO);
|
||||||
|
list.add(dayReportMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dayReportMap;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, DaySettlePrintDTO> buildDaySettlePrint(SaleSummaryCountParam param) {
|
private List<Map<String, Object>> buildDaySettlePrint(SaleSummaryCountParam param) {
|
||||||
Map<String, DaySettlePrintDTO> dayReportMap = new HashMap<>();
|
List<Map<String, Object>> map = new ArrayList<>();
|
||||||
if (param.getBeginDate() != null && param.getEndDate() != null) {
|
if (param.getBeginDate() != null && param.getEndDate() != null) {
|
||||||
|
Map<String, Object> dayReportMap = new HashMap<>();
|
||||||
// 计算相差天数
|
// 计算相差天数
|
||||||
long days = java.time.temporal.ChronoUnit.DAYS.between(param.getBeginDate(), param.getEndDate());
|
long days = java.time.temporal.ChronoUnit.DAYS.between(param.getBeginDate(), param.getEndDate());
|
||||||
List<LocalDate> dateList = LongStream.rangeClosed(0, days)
|
List<LocalDate> dateList = LongStream.rangeClosed(0, days)
|
||||||
@@ -285,10 +289,12 @@ public class FinanceStsServiceImpl implements FinanceStsService {
|
|||||||
printDTO.setOperationRecords(records);
|
printDTO.setOperationRecords(records);
|
||||||
|
|
||||||
//加入结果
|
//加入结果
|
||||||
dayReportMap.put(localDate.toString(), printDTO);
|
dayReportMap.put("date", localDate);
|
||||||
|
dayReportMap.put("data", printDTO);
|
||||||
|
map.add(dayReportMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dayReportMap;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class ShopProdStatisticServiceImpl extends ServiceImpl<ShopProdStatisticM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void summaryPrint(SaleSummaryCountParam param) {
|
public void summaryPrint(SaleSummaryCountParam param) {
|
||||||
Map<String, ProductReportPrintDTO> printDTO = new HashMap<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
// 1. 获取统计数据
|
// 1. 获取统计数据
|
||||||
Map<Long, String> categoryMap = shopProdCategoryService.getCategoryIdNameMap(param.getShopId());
|
Map<Long, String> categoryMap = shopProdCategoryService.getCategoryIdNameMap(param.getShopId());
|
||||||
if (param.getBeginDate() != null && param.getEndDate() != null) {
|
if (param.getBeginDate() != null && param.getEndDate() != null) {
|
||||||
@@ -97,15 +97,20 @@ public class ShopProdStatisticServiceImpl extends ServiceImpl<ShopProdStatisticM
|
|||||||
.mapToObj(param.getBeginDate()::plusDays)
|
.mapToObj(param.getBeginDate()::plusDays)
|
||||||
.toList();
|
.toList();
|
||||||
for (LocalDate localDate : dateList) {
|
for (LocalDate localDate : dateList) {
|
||||||
|
Map<String, Object> printDTO = new HashMap<>();
|
||||||
SaleSummaryCountParam queryDay = new SaleSummaryCountParam()
|
SaleSummaryCountParam queryDay = new SaleSummaryCountParam()
|
||||||
.setShopId(param.getShopId())
|
.setShopId(param.getShopId())
|
||||||
.setBeginDate(localDate)
|
.setBeginDate(localDate)
|
||||||
.setEndDate(localDate);
|
.setEndDate(localDate);
|
||||||
ProductReportPrintDTO print = buildProductReportPrint(queryDay, categoryMap);
|
ProductReportPrintDTO print = buildProductReportPrint(queryDay, categoryMap);
|
||||||
printDTO.put(localDate.toString(), print);
|
printDTO.put("date", localDate);
|
||||||
|
printDTO.put("data", print);
|
||||||
|
list.add(printDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rabbitPublisher.sendOtherPrintMsg(param.getShopId(), printDTO, "PRODUCT_REPORT");
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
|
rabbitPublisher.sendOtherPrintMsg(param.getShopId(), list, "PRODUCT_REPORT");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user