退没的商品 不展示
This commit is contained in:
@@ -266,7 +266,11 @@ public interface PrinterImpl {
|
|||||||
data.append(getFormatLabel(formatItemLine("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
data.append(getFormatLabel(formatItemLine("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
|
|
||||||
for (OrderDetail detail : detailList) {
|
for (OrderDetail detail : detailList) {
|
||||||
String number = detail.getNum().subtract(detail.getReturnNum()).stripTrailingZeros().toPlainString();
|
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
|
||||||
|
if (subtract.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String number = subtract.stripTrailingZeros().toPlainString();
|
||||||
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
|
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
|
||||||
data.append(getFormatLabel(formatItemLine(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
|
data.append(getFormatLabel(formatItemLine(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
|
|
||||||
@@ -347,7 +351,11 @@ public interface PrinterImpl {
|
|||||||
data.append(getFormatLabel(formatItemLine("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
data.append(getFormatLabel(formatItemLine("品名", "单价", "数量", 18, 9), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
|
|
||||||
for (OrderDetail detail : detailList) {
|
for (OrderDetail detail : detailList) {
|
||||||
String number = detail.getNum().subtract(detail.getReturnNum()).stripTrailingZeros().toPlainString();
|
BigDecimal subtract = detail.getNum().subtract(detail.getReturnNum());
|
||||||
|
if (subtract.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String number = subtract.stripTrailingZeros().toPlainString();
|
||||||
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
|
String unitPrice = toPlainStr(detail.getUnitPrice().stripTrailingZeros().toPlainString());
|
||||||
data.append(getFormatLabel(formatItemLine(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
|
data.append(getFormatLabel(formatItemLine(detail.getProductName(), unitPrice, number, 18, 7), signLabelInfo.s)).append(signLabelInfo.br);
|
||||||
|
|
||||||
@@ -774,23 +782,19 @@ public interface PrinterImpl {
|
|||||||
if (getStringWidth(text) <= maxWidth) {
|
if (getStringWidth(text) <= maxWidth) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
int currentWidth = 0;
|
int currentWidth = 0;
|
||||||
int ellipsisWidth = getStringWidth("...");
|
int ellipsisWidth = getStringWidth("...");
|
||||||
|
|
||||||
for (char c : text.toCharArray()) {
|
for (char c : text.toCharArray()) {
|
||||||
int charWidth = (c > 127) ? 2 : 1;
|
int charWidth = (c > 127) ? 2 : 1;
|
||||||
|
|
||||||
// 剩下的宽度必须能放下 当前字符 + ...
|
// 剩下的宽度必须能放下 当前字符 + ...
|
||||||
if (currentWidth + charWidth + ellipsisWidth > maxWidth) {
|
if (currentWidth + charWidth + ellipsisWidth > maxWidth) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
currentWidth += charWidth;
|
currentWidth += charWidth;
|
||||||
}
|
}
|
||||||
|
return sb + "..";
|
||||||
return sb + "..."; // 超长自动加...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user