Commit 7ef23438 by Wyh Committed by 宁斌

6.06 打印字體大小又優化了

parent 42e42857
......@@ -173,6 +173,7 @@ public class DefaultFormatPrinter implements FormatPrinter {
int end = (i + 1) * MAX_LONG_SIZE;
end = end > line.length() ? line.length() : end;
Timber.tag(tag).i(DEFAULT_LINE + line.substring(start, end));
Log.e("aaa", "" + DEFAULT_LINE + line.substring(start, end));
}
}
}
......
package com.gingersoft.gsa.cloud.base.utils;
import com.elvishew.xlog.XLog;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import static java.math.BigDecimal.ROUND_HALF_UP;
......
......@@ -147,6 +147,8 @@ public class LayoutToBitmapUtils {
//然后View和其内部的子View都具有了实际大小,也就是完成了布局,相当与添加到了界面上。接着就可以创建位图并在上面绘制了:
// DisplayMetrics metric = new DisplayMetrics();
// activity.getWindowManager().getDefaultDisplay().getMetrics(metric);
// int width = (int) (context.getResources().getDisplayMetrics().widthPixels *0.7); // 屏幕宽度(像素)
// int height = (int) (context.getResources().getDisplayMetrics().heightPixels *0.7); // 屏幕高度(像素)
int width = context.getResources().getDisplayMetrics().widthPixels; // 屏幕宽度(像素)
int height = context.getResources().getDisplayMetrics().heightPixels; // 屏幕高度(像素)
// 整个View的大小 参数是左上角 和右下角的坐标
......@@ -162,6 +164,7 @@ public class LayoutToBitmapUtils {
public static Bitmap loadBitmapFromView(View v) {
int w = v.getWidth();
// int w = 500;
int h = v.getHeight();
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bmp);
......
......@@ -22,26 +22,25 @@ public class ExpandInfo {
private Long id;
private int restaurantId;
/**功能建名称*/
/**
* 功能建名称
*/
private String settingName;
/**功能值*/
/**
* 功能值
*/
private Integer valueInt;
private String valueChar;
private String valueDatetime;
/**功能说明*/
/**
* 功能说明
*/
private String remark;
@Generated(hash = 1553907136)
public ExpandInfo(Long id, int restaurantId, String settingName,
Integer valueInt, String valueChar, String valueDatetime,
String remark) {
public ExpandInfo(Long id, int restaurantId, String settingName, Integer valueInt,
String valueChar, String valueDatetime, String remark) {
this.id = id;
this.restaurantId = restaurantId;
this.settingName = settingName;
......@@ -55,13 +54,6 @@ public class ExpandInfo {
public ExpandInfo() {
}
public Long getId() {
return this.id;
}
......
......@@ -308,14 +308,14 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
}
private void functionClick(String name, int status) {
switch (status){
case STATUS_NONACTIVATED:
ToastUtils.show(mContext, "服務暫未開通,敬請期待");
return;
case STATUS_TIME_LIMIT:
ToastUtils.show(mContext, "服務已到期,請前往續費");
return;
}
// switch (status){
// case STATUS_NONACTIVATED:
// ToastUtils.show(mContext, "服務暫未開通,敬請期待");
// return;
// case STATUS_TIME_LIMIT:
// ToastUtils.show(mContext, "服務已到期,請前往續費");
// return;
// }
if (name.equals("餐檯模式")) {
CC.obtainBuilder("Component.Table")
.setActionName("showTableActivity")
......
......@@ -267,7 +267,7 @@ public class SettlementReportActivity extends BaseActivity<SettlementReportPrese
String projectTotalSalesText = LanguageUtils.get_language_system(this, "total.project.sales", "項目銷售總額");
String discountText = LanguageUtils.get_language_system(this, "", "折扣");
String serviceFeeText = LanguageUtils.get_language_system(this, "", "服務費");
String deliveryFeeText = LanguageUtils.get_language_system(this, "", "配送費");
String deliveryFeeText = LanguageUtils.get_language_system(this, "", "送貨費");
String orderCountallText = LanguageUtils.get_language_system(this, "order.countall_litter", "賬單小數");
String netTurnoverText = LanguageUtils.get_language_system(this, "net.turnover", "營業金額淨值");
......
......@@ -10,7 +10,7 @@ class HistoryOrderRepository private constructor(private val network: CoolWeathe
suspend fun getHistoryOrderList(restaurantId: String, status: String, startDate: String, endDate: String, pageIndex: String, pageSize: String, orderNo: String = "", phone: String = "") = withContext(Dispatchers.IO) {
val requestBody = FormBody.Builder()
.add("restaurantId", restaurantId)
.add("status", status)
.add("status", status)//4為已完成 6為取消
.add("pageIndex", pageIndex)
.add("pageSize", pageSize)
.add("orderNo", orderNo)
......
......@@ -383,9 +383,9 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
}
if (third) {
// 如果是第三方物流,調用第三方接口
thirdSend(data, orderDetails, status, isPush, data.order_type, context, listener)
thirdSend(data, orderDetails, status, context, listener)
} else {
updateOrderAndPrint(data, status, isPush, orderDetails, context, listener)
updateOrderAndPrint(data, status, context, listener)
}
}
// } else {
......@@ -402,7 +402,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
* 修改訂單狀態並打印
*/
private suspend fun updateOrderAndPrint(data: OrderList.DataBeanX.DataBean, status: Int, isPush: Int, orderDetails: OrderDetails, context: Context, listener: (Boolean) -> Unit) {
private suspend fun updateOrderAndPrint(data: OrderList.DataBeanX.DataBean, status: Int, context: Context, listener: (Boolean) -> Unit) {
// updateOrderStatus(data.Id.toString(), "", status, "", "", isPush, data.order_type).apply {
//
// }
......@@ -457,7 +457,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
/**
* 第三方派送
*/
private suspend fun thirdSend(data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, status: Int, isPush: Int, orderType: Int, context: Context, listener: (Boolean) -> Unit) {
private suspend fun thirdSend(data: OrderList.DataBeanX.DataBean, orderDetails: OrderDetails, status: Int, context: Context, listener: (Boolean) -> Unit) {
val third = ThirdItem()
orderDetails.data?.get(0)?.PRODUCT_NAME?.let {
for (i in it) {
......@@ -474,7 +474,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
cancelDialogForLoading()
if (success) {
ToastUtils.show(context, "訂單派送成功")
updateOrderAndPrint(data, status, isPush, orderDetails, context, listener)
updateOrderAndPrint(data, status, context, listener)
} else {
ToastUtils.show(context, "訂單派送失敗")
}
......
......@@ -278,7 +278,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="配送費"
android:text="送貨費費"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
......
......@@ -499,7 +499,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="配送費:"
android:text="送貨費:"
android:visibility="@{data.dELIVERY_CHARGE==0?View.GONE:View.VISIBLE}"
app:layout_constraintRight_toRightOf="@id/tv_total_text"
app:layout_constraintTop_toBottomOf="@id/tv_lunchbox_cost" />
......
......@@ -47,7 +47,7 @@
<string name="delivery_type">配送類型:</string>
<string name="delivery_expenses">配送費範圍:</string>
<string name="delivery_fee">起送費:</string>
<string name="delivery_fee">最低消費:</string>
<string name="delivery_method">配送方式:</string>
<string name="delivery_difference">補差價:</string>
......
......@@ -15,6 +15,10 @@ import com.gingersoft.gsa.cloud.base.common.bean.mealManage.MyOrderManage;
import com.gingersoft.gsa.cloud.base.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.base.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.base.utils.view.ImageUtils;
import com.gingersoft.gsa.cloud.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.database.bean.ExpandInfo;
import com.gingersoft.gsa.cloud.database.utils.ExpandInfoDaoUtils;
import com.joe.print.mvp.model.bean.PrintBillBean;
import com.joe.print.mvp.ui.adapter.BillItemAdapter;
import com.joe.print.mvp.ui.adapter.OtherOrderAdapter;
......@@ -23,6 +27,7 @@ import com.joe.print.R;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -33,6 +38,19 @@ public class PrintOtherOrder extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
OrderDetails.DataBean dataBean = MyOrderManage.getDataBean();
ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(mContext);
List<ExpandInfo> expandInfos = expandInfoDaoUtils.queryAllExpandInfo();
int printCount = 1;
if (expandInfos != null) {
for (ExpandInfo expandInfo : expandInfos) {
if (expandInfo.getSettingName().equals(ExpandConstant.DeliveryPrintCount)) {
printCount = expandInfo.getValueInt();
}
}
}
if (dataBean != null) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
//廚房單,可能會有多個IP打印
......@@ -125,13 +143,22 @@ public class PrintOtherOrder extends PrinterRoot {
}
//如果需要打印印單,加上
List<Bitmap> bitmaps = new ArrayList<>();
bitmaps.add(initPrintView(mContext, dataBean));
Bitmap bitmap = initPrintView(mContext, dataBean);
bitmaps.add(bitmap);
merge2ResultMap(bitmapMaps, "", bitmaps);
return bitmapMaps;
}
return null;
}
private void addCountBitmap(List<Bitmap> bitmaps, int count, Bitmap bitmap) {
for (int i = 0; i < count; i++) {
bitmaps.add(bitmap);
}
}
private void addToMap(Map<String, List<OrderDetails.DataBean.PRODUCTNAMEBean>> foodMaps, OrderDetails.DataBean.PRODUCTNAMEBean food) {
if (foodMaps.get(food.getPrintseting()) != null) {
Objects.requireNonNull(foodMaps.get(food.getPrintseting())).add(food);
......@@ -202,6 +229,7 @@ public class PrintOtherOrder extends PrinterRoot {
RecyclerView rvBill = view.findViewById(R.id.rv_bill);
List<PrintBillBean> billData = new ArrayList<>();
billData.add(getBillBean("合計:", amountUnit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getLunchbox()),data.getDELIVERY_CHARGE())));
if (data.getLunchbox() != 0) {
billData.add(getBillBean("餐盒費:", amountUnit + data.getLunchbox()));
}
......@@ -213,13 +241,20 @@ public class PrintOtherOrder extends PrinterRoot {
billData.add(getBillBean(coupon.getCouponName() + ":", "-$" + coupon.getDiscount_amount()));
}
}
billData.add(getBillBean("總金額:", amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount())));
//總金額減去餐盒費之後的價格
// double amount1 = MoneyUtil.sub(Double.parseDouble(Objects.requireNonNull(data.getTOTAL_AMOUNT())), data.getLunchbox());
//總金額減去餐盒費、減去配送費之後的價格
// double amount2 = MoneyUtil.sub(amount1, data.getDELIVERY_CHARGE());
//總金額減去餐盒費、減去配送費、減去折扣之後的價格
// double amount3 = MoneyUtil.sub(amount2, data.getDiscount_amount());
// billData.add(getBillBean("總金額:", amountUnit + data.getTOTAL_AMOUNT()));
BillItemAdapter adapter = new BillItemAdapter(billData, context);
rvBill.setLayoutManager(new LinearLayoutManager(context));
rvBill.setAdapter(adapter);
//合計
setText(view, R.id.tv_total, amountUnit + MoneyUtil.sub(MoneyUtil.sub(Double.parseDouble(Objects.requireNonNull(data.getTOTAL_AMOUNT())), data.getLunchbox()), data.getDELIVERY_CHARGE()));
//總金額
setText(view, R.id.tv_total, amountUnit + data.getTOTAL_AMOUNT());
//支付金額
setText(view, R.id.tv_pay_amount_text, "支付金額:" + amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
//支付類型:貨到付款,在線支付
......
......@@ -39,8 +39,13 @@ import com.joe.print.mvp.ui.adapter.PrintFileBitmapAdapter;
import com.sunmi.peripheral.printer.InnerResultCallbcak;
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -112,9 +117,49 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
resultMap.put(key2, value);
}
}
if(resultMap.size() == 0){
// resultMap.put(key2, value);
}
return resultMap;
}
public static <E,T> Map<E,T> deepCopy(Map<E,T> src) {
try {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(src);
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteIn);
@SuppressWarnings("unchecked")
Map<E,T> dest = (Map<E,T> ) in.readObject();
return dest;
} catch (Exception e) {
e.printStackTrace();
return new HashMap<E,T>();
}
}
@SuppressWarnings("unchecked")
public static <E,T> Map<E,T> deepClone(Map<E,T> obj){
T clonedObj = null;
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
oos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
clonedObj = (T) ois.readObject();
ois.close();
}catch (Exception e){
e.printStackTrace();
}
return (Map) clonedObj;
}
/**
* @param mContext
* @return key為打印位置,值為圖片集合的map
......
......@@ -35,8 +35,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textSize="@dimen/dp_35"
android:text='外送' />
android:text='外送'
android:textSize="@dimen/dp_35" />
<TextView
style="@style/print_other_order_twenty_six_style"
......@@ -95,7 +95,7 @@
style="@style/print_other_order_thirty_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="@dimen/dp_50"
android:textStyle="bold" />
<TextView
......@@ -155,9 +155,18 @@
android:maxLines="1"
android:text="@string/print_split_line" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_bill"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
app:layout_constraintTop_toBottomOf="@id/tv_total_text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_total_text"
......@@ -165,7 +174,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="合計:"
android:text="總金額:"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
......@@ -182,13 +191,6 @@
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_bill"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
app:layout_constraintTop_toBottomOf="@id/tv_total_text" />
<TextView
style="@style/print_other_order_twenty_six_style"
android:layout_width="match_parent"
......@@ -201,8 +203,7 @@
style="@style/print_other_order_thirty_bold_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="支付金額:"
android:textSize="@dimen/dp_26" />
android:text="支付金額:" />
<TextView
style="@style/print_other_order_twenty_six_style"
......
......@@ -6,21 +6,21 @@
<!-- 接單的廚房單-->
<TextView
android:id="@+id/tv_order_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/theme_333_color"
android:textStyle="bold"
android:textSize="@dimen/dp_34" />
<TextView
android:id="@+id/tv_order_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_72"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_order_number"
style="@style/print_other_order_twenty_six_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單號:"
android:textColor="@color/theme_333_color" />
<TextView
android:id="@+id/tv_order_number"
style="@style/print_other_order_twenty_six_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單號:"
android:textColor="@color/theme_333_color" />
<TextView
android:id="@+id/tv_order_create_time"
......@@ -36,6 +36,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:textSize="@dimen/dp_50"
android:text="取餐碼:"
android:textStyle="bold" />
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_6">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintHorizontal_weight="0.6"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_food_number"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_food_item_next"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/item_next"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/tv_food_name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_food_name" />
<TextView
android:id="@+id/tv_food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="@style/print_other_order_twenty_six_style"
app:layout_constraintLeft_toRightOf="@id/iv_food_item_next"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/tv_food_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
style="@style/print_other_order_twenty_six_style"
app:layout_constraintHorizontal_weight="0.2"
app:layout_constraintLeft_toRightOf="@id/layout_food_name"
app:layout_constraintRight_toLeftOf="@id/tv_food_price"
app:layout_constraintTop_toTopOf="@id/layout_food_name" />
<TextView
android:id="@+id/tv_food_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
style="@style/print_other_order_twenty_six_style"
android:visibility="invisible"
app:layout_constraintHorizontal_weight="0.2"
app:layout_constraintLeft_toRightOf="@id/tv_food_number"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/layout_food_name" />
<LinearLayout
android:id="@+id/layout_food_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@id/layout_food_name" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -23,6 +23,11 @@
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_18</item>
</style>
<style name="print_other_order_food_style">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_34</item>
</style>
<style name="print_other_order_twenty_six_style">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_26</item>
......
......@@ -10,23 +10,24 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import model.UpdateBean;
import service.UpdateAppService;
import teprinciple.updateapputils.R;
import util.DownloadAppUtils;
import util.UpdateAppUtils;
import view.ConfirmDialog;
import view.DownloadDialog;
/**
* 作者:ELEGANT_BIN
......
......@@ -5,7 +5,9 @@ import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import util.UpdateAppReceiver;
/**
......
......@@ -8,8 +8,8 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.support.v4.content.FileProvider;
import android.webkit.DownloadListener;
import androidx.core.content.FileProvider;
import java.io.File;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment