打印样式修改
This commit is contained in:
parent
cb1d05a042
commit
e5da3ebb30
|
|
@ -24,6 +24,7 @@ public class TbMerchantThirdApply implements Serializable {
|
|||
private String appToken;
|
||||
|
||||
private String smallAppid;
|
||||
private String alipaySmallAppid;
|
||||
|
||||
private String storeId;
|
||||
|
||||
|
|
@ -124,4 +125,12 @@ public class TbMerchantThirdApply implements Serializable {
|
|||
public void setStoreId(String storeId) {
|
||||
this.storeId = storeId;
|
||||
}
|
||||
|
||||
public String getAlipaySmallAppid() {
|
||||
return alipaySmallAppid;
|
||||
}
|
||||
|
||||
public void setAlipaySmallAppid(String alipaySmallAppid) {
|
||||
this.alipaySmallAppid = alipaySmallAppid;
|
||||
}
|
||||
}
|
||||
|
|
@ -135,6 +135,7 @@ public class PrintConsumer {
|
|||
|
||||
|
||||
private List<TbPrintMachine> getPrintMachine(Integer shopId, String subType, String printMethod, String printType) {
|
||||
|
||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(shopId);
|
||||
if (ObjectUtil.isEmpty(shopInfo)) {
|
||||
log.error("店铺信息不存在");
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class FeiPrinter extends PrinterHandler {
|
|||
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
||||
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,
|
||||
(ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
|
||||
"0", detailList, orderInfo.getRemark(), null, null);
|
||||
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount()==null?null:orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio()==null?null:orderInfo.getDiscountRatio().toPlainString());
|
||||
String printType = "结算单";
|
||||
String[] resp = FeieyunPrintUtil.getCashPrintData(detailPO, machine.getAddress(), printType, printType);
|
||||
shopPrintLogService.save(machine, "结算单", resp[0], resp[1]);
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ public class CloudPrinterService {
|
|||
ObjectUtil.isEmpty(orderInfo.getMasterId()) || ObjectUtil.isNull(orderInfo.getMasterId()) ? orderInfo.getTableName() : orderInfo.getMasterId(),
|
||||
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
||||
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance, orderInfo.getPayType(), "0",
|
||||
detailList, orderInfo.getRemark(), null, null);
|
||||
detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount()==null?null:orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio()==null?null:orderInfo.getDiscountRatio().toPlainString());
|
||||
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||
String printType = "退款单";
|
||||
|
||||
|
|
@ -472,7 +472,7 @@ public class CloudPrinterService {
|
|||
orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())),
|
||||
"【POS-1】001", orderInfo.getOrderAmount().toPlainString(),
|
||||
balance, (ObjectUtil.isEmpty(orderInfo.getPayType()) || ObjectUtil.isNull(orderInfo.getPayType()) ? "" : orderInfo.getPayType()),
|
||||
"0", detailList, orderInfo.getRemark(), null, null);
|
||||
"0", detailList, orderInfo.getRemark(), orderInfo.getDiscountAmount()==null?null:orderInfo.getDiscountAmount().toPlainString(), orderInfo.getDiscountRatio()==null?null:orderInfo.getDiscountRatio().toPlainString());
|
||||
String printType = "结算单";
|
||||
if (ispre) {
|
||||
printType = "预结算单";
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ public class ShopPrintLogServiceImpl extends ServiceImpl<TbPrintMachineLogMapper
|
|||
entity.setRespMsg("打印成功");
|
||||
} else {
|
||||
String msg = FeieyunPrintUtil.checkOnline(entity.getAddress());
|
||||
if (msg.indexOf("在线") > 0) {
|
||||
if (msg.indexOf("在线,工作状态正常") > 0) {
|
||||
entity.setFailFlag(0);
|
||||
entity.setPrintTime(new Date());
|
||||
entity.setRespMsg("打印成功");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,143 @@
|
|||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2024-10-15 15:12
|
||||
*/
|
||||
@UtilityClass
|
||||
public class FeieYunUtil {
|
||||
|
||||
public String titleAddSpace(String str, int b1) {
|
||||
int k = 0;
|
||||
int b = b1;
|
||||
try {
|
||||
k = str.getBytes("GBK").length;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (int i = 0; i < b - k; i++) {
|
||||
str += " ";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String getStringByEnter(int length, String string) throws Exception {
|
||||
for (int i = 1; i <= string.length(); i++) {
|
||||
if (string.substring(0, i).getBytes("GBK").length > length) {
|
||||
return string.substring(0, i - 1) + "<BR>" + getStringByEnter(length, string.substring(i - 1));
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String addSpace(String str, int size) {
|
||||
int len = str.length();
|
||||
if (len < size) {
|
||||
for (int i = 0; i < size - len; i++) {
|
||||
str += " ";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static Boolean isEn(String str) {
|
||||
Boolean b = false;
|
||||
try {
|
||||
b = str.getBytes("GBK").length == str.length();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
public static List<String> getStrList(String inputString, int length) {
|
||||
int size = inputString.length() / length;
|
||||
if (inputString.length() % length != 0) {
|
||||
size += 1;
|
||||
}
|
||||
return getStrList(inputString, length, size);
|
||||
}
|
||||
|
||||
public static List<String> getStrList(String inputString, int length, int size) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (int index = 0; index < size; index++) {
|
||||
String childStr = substring(inputString, index * length, (index + 1) * length);
|
||||
list.add(childStr);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String substring(String str, int f, int t) {
|
||||
if (f > str.length()) {
|
||||
return null;
|
||||
}
|
||||
if (t > str.length()) {
|
||||
return str.substring(f, str.length());
|
||||
} else {
|
||||
return str.substring(f, t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对齐后的小票明细行数据
|
||||
* 58mm的机器,一行打印16个汉字,32个字母;80mm的机器,一行打印24个汉字,48个字母
|
||||
* b1代表名称列占用字节 b2单价列 b3数量列 b4金额列-->这里的字节数可按自己需求自由改写
|
||||
*
|
||||
* @param title 品名
|
||||
* @param price 单价
|
||||
* @param num 数量
|
||||
* @param total 小计
|
||||
* @param b1 品名占用字节
|
||||
* @param b2 单价占用字节
|
||||
* @param b3 数量占用字节
|
||||
* @param b4 小计占用字节
|
||||
* @return 对齐后的行数据
|
||||
*/
|
||||
public static String getRow(String title, String price, String num, String total, int b1, int b2, int b3, int b4) {
|
||||
price = addSpace(price, b2);
|
||||
num = addSpace(num, b3);
|
||||
total = addSpace(total, b4);
|
||||
String otherStr = " " + price + num + " " + total;
|
||||
int tl = 0;
|
||||
try {
|
||||
tl = title.getBytes("GBK").length;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int spaceNum = (tl / b1 + 1) * b1 - tl;
|
||||
if (tl < b1) {
|
||||
for (int k = 0; k < spaceNum; k++) {
|
||||
title += " ";
|
||||
}
|
||||
title += otherStr;
|
||||
} else if (tl == b1) {
|
||||
title += otherStr;
|
||||
} else {
|
||||
List<String> list = null;
|
||||
if (isEn(title)) {
|
||||
list = getStrList(title, b1);
|
||||
} else {
|
||||
list = getStrList(title, b1 / 2);
|
||||
}
|
||||
String s0 = titleAddSpace(list.get(0), b1);
|
||||
title = s0 + otherStr + "<BR>";// 添加 单价 数量 总额
|
||||
String s = "";
|
||||
for (int k = 1; k < list.size(); k++) {
|
||||
s += list.get(k);
|
||||
}
|
||||
try {
|
||||
s = getStringByEnter(b1, s);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
title += s;
|
||||
}
|
||||
return title + "<BR>";
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
|
||||
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
||||
<result column="small_appid" jdbcType="VARCHAR" property="smallAppid" />
|
||||
<result column="alipay_small_appid" jdbcType="VARCHAR" property="alipaySmallAppid" />
|
||||
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbMerchantThirdApply">
|
||||
|
|
@ -19,7 +20,7 @@
|
|||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, type, app_id, status, pay_password, applyment_state, created_at, updated_at,
|
||||
shop_id,small_appid,store_id
|
||||
shop_id,small_appid,alipay_small_appid,store_id
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
app_token
|
||||
|
|
|
|||
Loading…
Reference in New Issue