添加交班时间

This commit is contained in:
牛叉闪闪
2024-07-22 14:11:48 +08:00
parent cda3245f7b
commit 60267f5576
13 changed files with 284 additions and 21 deletions

View File

@@ -1,6 +1,8 @@
package com.chaozhanggui.system.cashierservice.util;
import cn.hutool.core.util.ObjectUtil;
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo;
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO;
import com.chaozhanggui.system.cashierservice.model.HandoverInfo;
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
import org.springframework.http.HttpEntity;
@@ -199,6 +201,80 @@ public class PrinterUtils {
}
}
if(ObjectUtil.isNotEmpty(handoverInfo.getProductInfos())&&handoverInfo.getProductInfos().size()>0) {
sb.append("<S>商品数据</S><BR>");
char paddingCharacter = ' ';
sb.append("<S> "+String.format("%-10s","品名").replace(' ', paddingCharacter)+String.format("%-4s","数量").replace(' ', paddingCharacter)+String.format("%4s","小计").replace(' ', paddingCharacter)+"</S><BR>");
for (ProductInfo productInfo : handoverInfo.getProductInfos()) {
if(productInfo.getProductName().length()>4&&productInfo.getProductName().length()<=8){
int count=getProducrName(productInfo.getProductName());
if(count<=0){
int length=15-(productInfo.getProductName().length()-4);
sb.append("<S> "+String.format("%-"+length+"s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%4s",productInfo.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}else {
int length=15+count/2-(productInfo.getProductName().length()-4);
sb.append("<S> "+String.format("%-"+length+"s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%4s",productInfo.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}
}else if(productInfo.getProductName().length()>10){
sb.append("<S> "+productInfo.getProductName()+"</S><BR>");
sb.append("<S> "+String.format("%20s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%11s",productInfo.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}else {
sb.append("<S> "+String.format("%-10s",productInfo.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfo.getNum()).replace(' ', paddingCharacter)+String.format("%6s",productInfo.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}
sb.append("<BR>");
}
}
if(ObjectUtil.isNotEmpty(handoverInfo.getProductInfoPOS())&&handoverInfo.getProductInfoPOS().size()>0){
sb.append("<S>商品数据</S><BR>");
char paddingCharacter = ' ';
for (ProductInfoPO productInfoPO : handoverInfo.getProductInfoPOS()) {
if(ObjectUtil.isNotEmpty(productInfoPO.getSkuName())){
productInfoPO.setProductName(productInfoPO.getProductName().concat("(").concat(productInfoPO.getSkuName()).concat(")"));
}
if(productInfoPO.getProductName().length()>4&&productInfoPO.getProductName().length()<=10){
int count=getProducrName(productInfoPO.getProductName());
if(count<=0){
int length=15-(productInfoPO.getProductName().length()-4);
sb.append("<S>"+String.format("%-"+length+"s",productInfoPO.getProductName()).replace(' ', paddingCharacter)+String.format("%-2s", productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%8s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}else {
int length=15+count-(productInfoPO.getProductName().length()-4);
sb.append("<S>"+String.format("%-"+length+"s",productInfoPO.getProductName()).replace(' ', paddingCharacter)+String.format("%-2s",productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%8s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}
}else if(productInfoPO.getProductName().length()>10){
sb.append("<S>"+productInfoPO.getProductName()+"</S><BR>");
sb.append("<S>"+String.format("%20s",productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%11s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}else {
sb.append("<S>"+String.format("%-15s",productInfoPO.getProductName()).replace(' ', paddingCharacter)+String.format("%-4s",productInfoPO.getNum()).replace(' ', paddingCharacter)+String.format("%8s",productInfoPO.getAmount()).replace(' ', paddingCharacter)+"</S><BR>");
}
sb.append("<BR>");
}
}
sb.append("<S>快捷收款金额 :".concat(ObjectUtil.isNull(handoverInfo.getQuickAmount())?"0":handoverInfo.getQuickAmount())+"</S><BR>");
sb.append("<S>退款金额 :".concat(handoverInfo.getReturnAmount())+"</S><BR>");
sb.append("<S>总收入: "+handoverInfo.getTotalAmount()+"</S><BR>");
@@ -279,22 +355,35 @@ public class PrinterUtils {
public static int getProducrName(String str){
int count = 0;
int digitCount=0;
for (int i=0;i<str.length();i++){
if ((str.charAt(i)>='a' && str.charAt(i)<='z') || (str.charAt(i)>='A' && str.charAt(i)<='Z')){
int count=0;
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c >= '0' && c <= '9') {
count++;
} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
count++;
}
if (Character.isDigit(str.charAt(i))) {
digitCount++;
}
}
return count+digitCount;
return count;
}
public static void main(String[] args)throws Exception {
int t=0;
String str="张三456987asdfg";
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (c >= '0' && c <= '9') {
t++;
} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
t++;
}
}
System.out.println(t);
//
// List<HandoverInfo.PayInfo> payInfos=new ArrayList<>();
//
@@ -331,8 +420,8 @@ public class PrinterUtils {
String voiceJson = "{\"bizType\":\"1\",\"content\":\"您有一笔新的订单,请及时处理\"}";
printTickets(voiceJson,1,1,"ZF544PG03W00002", printInvoice("http://weixin.qq.com/q/020fVS8lcLeiG1ID3SxCcH","【30天内开票有效】","1000000"));
// String voiceJson = "{\"bizType\":\"1\",\"content\":\"您有一笔新的订单,请及时处理\"}";
// printTickets(voiceJson,1,1,"ZF544PG03W00002", printInvoice("http://weixin.qq.com/q/020fVS8lcLeiG1ID3SxCcH","【30天内开票有效】","1000000"));
}
}