打印
This commit is contained in:
@@ -2,6 +2,7 @@ package com.czg.mq;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.config.RabbitConstants;
|
import com.czg.config.RabbitConstants;
|
||||||
import com.czg.config.RabbitPublisher;
|
import com.czg.config.RabbitPublisher;
|
||||||
@@ -99,15 +100,23 @@ public class PrintMqListener {
|
|||||||
Long shopId = jsonObject.getLong("shopId");
|
Long shopId = jsonObject.getLong("shopId");
|
||||||
String printTypeEnum = jsonObject.getString("printTypeEnum");
|
String printTypeEnum = jsonObject.getString("printTypeEnum");
|
||||||
JSONObject data2 = jsonObject.getJSONObject("data");
|
JSONObject data2 = jsonObject.getJSONObject("data");
|
||||||
|
JSONArray data3 = null;
|
||||||
|
if (data2 == null) {
|
||||||
|
data3 = jsonObject.getJSONArray("data");
|
||||||
|
}
|
||||||
PrinterHandler.PrintTypeEnum typeEnum = PrinterHandler.PrintTypeEnum.valueOf(printTypeEnum);
|
PrinterHandler.PrintTypeEnum typeEnum = PrinterHandler.PrintTypeEnum.valueOf(printTypeEnum);
|
||||||
if (typeEnum != PrinterHandler.PrintTypeEnum.HANDOVER) {
|
if (typeEnum != PrinterHandler.PrintTypeEnum.HANDOVER) {
|
||||||
SysPrintData sysPrintData = new SysPrintData();
|
SysPrintData sysPrintData = new SysPrintData();
|
||||||
sysPrintData.setShopId(shopId);
|
sysPrintData.setShopId(shopId);
|
||||||
sysPrintData.setData(data2.toJSONString());
|
if (data2 != null) {
|
||||||
|
sysPrintData.setData(data2.toJSONString());
|
||||||
|
} else {
|
||||||
|
sysPrintData.setData(data3.toJSONString());
|
||||||
|
}
|
||||||
sysPrintData.setType(typeEnum.toString());
|
sysPrintData.setType(typeEnum.toString());
|
||||||
printDataService.save(sysPrintData);
|
printDataService.save(sysPrintData);
|
||||||
rabbitPublisher.sendOtherPrintLocalMsg(shopId, printTypeEnum, sysPrintData.getId());
|
rabbitPublisher.sendOtherPrintLocalMsg(shopId, printTypeEnum, sysPrintData.getId());
|
||||||
}
|
}
|
||||||
printConfig.otherHandler(shopId, data2, typeEnum);
|
printConfig.otherHandler(shopId, data2, data3, typeEnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.czg.service.order.print;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
|
||||||
import com.czg.account.dto.HandoverRecordDTO;
|
import com.czg.account.dto.HandoverRecordDTO;
|
||||||
import com.czg.account.entity.PrintMachine;
|
import com.czg.account.entity.PrintMachine;
|
||||||
import com.czg.account.entity.ShopInfo;
|
import com.czg.account.entity.ShopInfo;
|
||||||
@@ -185,7 +185,7 @@ public class PrintConfig implements ApplicationRunner {
|
|||||||
* @param data 传递的数据
|
* @param data 传递的数据
|
||||||
* @param printTypeEnum IN_STOCK DAY_REPORT PRODUCT_REPORT RECHARGE STOCK_CHECK
|
* @param printTypeEnum IN_STOCK DAY_REPORT PRODUCT_REPORT RECHARGE STOCK_CHECK
|
||||||
*/
|
*/
|
||||||
public void otherHandler(Long shopId, JSONObject data, PrinterHandler.PrintTypeEnum printTypeEnum) {
|
public void otherHandler(Long shopId, JSONObject data, JSONArray data1, PrinterHandler.PrintTypeEnum printTypeEnum) {
|
||||||
if (shopId == null || Objects.isNull(data)) {
|
if (shopId == null || Objects.isNull(data)) {
|
||||||
log.info("otherHandler 打印数据为空, shopId: {}, data: {}", shopId, data);
|
log.info("otherHandler 打印数据为空, shopId: {}, data: {}", shopId, data);
|
||||||
return;
|
return;
|
||||||
@@ -198,32 +198,29 @@ 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:
|
||||||
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());
|
||||||
for (Map<String, Object> map : list) {
|
for (Object obj : data1) {
|
||||||
printer.dayReportPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(map.get("data").toString(), DayReportPrintDTO.class));
|
JSONObject item = (JSONObject) obj;
|
||||||
|
printer.dayReportPrint(machine, shopInfo.getShopName(), item.getObject("data", DayReportPrintDTO.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PrinterHandler.PrintTypeEnum.DAY_ORDER:
|
case PrinterHandler.PrintTypeEnum.DAY_ORDER:
|
||||||
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());
|
||||||
for (Map<String, Object> map : list2) {
|
for (Object obj : data1) {
|
||||||
printer.daySettlePrint(machine, shopInfo.getShopName(), JSONObject.parseObject(map.get("data").toString(), DaySettlePrintDTO.class));
|
JSONObject item = (JSONObject) obj;
|
||||||
|
printer.daySettlePrint(machine, shopInfo.getShopName(), item.getObject("data", DaySettlePrintDTO.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PrinterHandler.PrintTypeEnum.PRODUCT_REPORT:
|
case PrinterHandler.PrintTypeEnum.PRODUCT_REPORT:
|
||||||
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());
|
||||||
for (Map<String, Object> map : list3) {//ProductReportPrintDTO
|
for (Object obj : data1) {
|
||||||
printer.productReportPrint(machine, shopInfo.getShopName(), JSONObject.parseObject(map.get("data").toString(), ProductReportPrintDTO.class));
|
JSONObject item = (JSONObject) obj;
|
||||||
|
printer.productReportPrint(machine, shopInfo.getShopName(), item.getObject("data", ProductReportPrintDTO.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user