打印问题
This commit is contained in:
@@ -2,6 +2,7 @@ package com.czg.order.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.order.dto.LimitRateDTO;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
@@ -346,15 +347,38 @@ public class OrderInfo implements Serializable {
|
||||
// .add(this.getRoundAmount() != null ? this.getRoundAmount() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
private JSONArray getPrintStatusAsArray() {
|
||||
if (StrUtil.isBlank(printStatus)) {
|
||||
return new JSONArray();
|
||||
}
|
||||
try {
|
||||
return JSONArray.parseArray(printStatus.trim());
|
||||
} catch (Exception e) {
|
||||
return new JSONArray();
|
||||
}
|
||||
}
|
||||
|
||||
// public JSONArray getPrintStatus() {
|
||||
// if (StrUtil.isBlank(printStatus)) {
|
||||
// return new JSONArray();
|
||||
// }
|
||||
// try {
|
||||
// return JSONArray.parseArray(printStatus.trim());
|
||||
// } catch (Exception e) {
|
||||
// return new JSONArray();
|
||||
// }
|
||||
// }
|
||||
public void upPrintStatus(JSONObject printStatus, boolean isPrintSuccess) {
|
||||
String currentDeviceId = printStatus.getString("id");
|
||||
JSONArray oldPrintStatusArray = getPrintStatusAsArray();
|
||||
// 3. 初始化新的打印状态JSON数组(用于存储处理后的结果)
|
||||
JSONArray newPrintStatusArray = new JSONArray();
|
||||
// 场景1:打印成功 - 移除原有数组中与当前设备ID一致的记录,保留其余记录
|
||||
if (oldPrintStatusArray != null && !oldPrintStatusArray.isEmpty()) {
|
||||
for (int i = 0; i < oldPrintStatusArray.size(); i++) {
|
||||
JSONObject deviceObj = oldPrintStatusArray.getJSONObject(i);
|
||||
String deviceId = deviceObj.getString("id");
|
||||
// 仅保留非当前设备ID的记录
|
||||
if (currentDeviceId != null && !currentDeviceId.equals(deviceId)) {
|
||||
newPrintStatusArray.add(deviceObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPrintSuccess) {
|
||||
newPrintStatusArray.add(printStatus);
|
||||
}
|
||||
if(newPrintStatusArray.isEmpty()){
|
||||
this.setPrintStatus(newPrintStatusArray.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.czg.order.entity.PrintMachineLog;
|
||||
* @since 2025-03-11
|
||||
*/
|
||||
public interface PrintMachineLogService extends IService<PrintMachineLog> {
|
||||
void save(Long orderId, PrintMachine config, String bizType, String printContent, String respJson);
|
||||
|
||||
void save(PrintMachine config, String bizType, String printContent, String respJson);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user