Commit c1d4845a by Wyh

7.17 針式打印帶顏色,斜體,加粗樣式PRJ單。打印機新增配置,打印新增通用配置。打印邏輯修改。BUG文檔內容修改

parent 786854c5
...@@ -197,7 +197,10 @@ public class OrderDetail implements Serializable { ...@@ -197,7 +197,10 @@ public class OrderDetail implements Serializable {
public static final byte FOOD_TYPE = 3; public static final byte FOOD_TYPE = 3;
public static final byte MODIFIER_TYPE = 4; public static final byte MODIFIER_TYPE = 4;
public static final byte DISCOUNT_TYPE = 5; public static final byte DISCOUNT_TYPE = 5;
/**
* 廚房單打印主項
*/
private long ktPrintMainItem;
public OrderDetail() { public OrderDetail() {
} }
...@@ -245,6 +248,7 @@ public class OrderDetail implements Serializable { ...@@ -245,6 +248,7 @@ public class OrderDetail implements Serializable {
this.discountStatus = orderDetail.discountStatus; this.discountStatus = orderDetail.discountStatus;
this.status = orderDetail.status; this.status = orderDetail.status;
this.printSeting = orderDetail.printSeting; this.printSeting = orderDetail.printSeting;
this.ktPrintMainItem = orderDetail.ktPrintMainItem;
} }
public int getSelected() { public int getSelected() {
...@@ -599,6 +603,14 @@ public class OrderDetail implements Serializable { ...@@ -599,6 +603,14 @@ public class OrderDetail implements Serializable {
this.discountStatus = discountStatus; this.discountStatus = discountStatus;
} }
public long getKtPrintMainItem() {
return ktPrintMainItem;
}
public void setKtPrintMainItem(long ktPrintMainItem) {
this.ktPrintMainItem = ktPrintMainItem;
}
/** /**
* 已送單食品轉換 * 已送單食品轉換
* *
...@@ -794,6 +806,7 @@ public class OrderDetail implements Serializable { ...@@ -794,6 +806,7 @@ public class OrderDetail implements Serializable {
public static OrderDetail modifierTransOrderDetail(Modifier modifier, long id, long productId, int number) { public static OrderDetail modifierTransOrderDetail(Modifier modifier, long id, long productId, int number) {
OrderDetail orderDetail = new OrderDetail(); OrderDetail orderDetail = new OrderDetail();
orderDetail.setProductName(modifier.getModifierName()); orderDetail.setProductName(modifier.getModifierName());
modifier.getKtPrintMainItem();
orderDetail.setTopId(modifier.getTopId()); orderDetail.setTopId(modifier.getTopId());
orderDetail.setParentId(id); orderDetail.setParentId(id);
orderDetail.setProductId(modifier.getMid()); orderDetail.setProductId(modifier.getMid());
......
...@@ -7,8 +7,6 @@ import android.graphics.Bitmap; ...@@ -7,8 +7,6 @@ import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -16,7 +14,6 @@ import android.view.View; ...@@ -16,7 +14,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
...@@ -25,6 +22,9 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy; ...@@ -25,6 +22,9 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.gingersoft.gsa.cloud.base.R; import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.ui.view.WheelView;
import java.util.List;
/** /**
* Created by Wyh on 2019/11/1. * Created by Wyh on 2019/11/1.
...@@ -34,7 +34,7 @@ public abstract class DialogUtils { ...@@ -34,7 +34,7 @@ public abstract class DialogUtils {
private static Dialog dialog; private static Dialog dialog;
private View view; private View view;
private int style = R.style.PhotoDialog; private int style = R.style.PhotoDialog;
// private int mWidth = WindowManager.LayoutParams.WRAP_CONTENT; // private int mWidth = WindowManager.LayoutParams.WRAP_CONTENT;
// private int mHeight = WindowManager.LayoutParams.WRAP_CONTENT; // private int mHeight = WindowManager.LayoutParams.WRAP_CONTENT;
private ViewHepler viewHepler; private ViewHepler viewHepler;
...@@ -43,7 +43,7 @@ public abstract class DialogUtils { ...@@ -43,7 +43,7 @@ public abstract class DialogUtils {
init(mContext); init(mContext);
} }
private void init(Context context) { private void init(Context context) {
dismiss(); dismiss();
dialog = new Dialog(context); dialog = new Dialog(context);
viewHepler = getViewHepler(context); viewHepler = getViewHepler(context);
...@@ -67,7 +67,7 @@ public abstract class DialogUtils { ...@@ -67,7 +67,7 @@ public abstract class DialogUtils {
public DialogUtils setWidth(int width) { public DialogUtils setWidth(int width) {
if (dialog != null) { if (dialog != null) {
Window window = dialog.getWindow(); Window window = dialog.getWindow();
if(window != null) { if (window != null) {
WindowManager.LayoutParams p = window.getAttributes(); // 获取对话框当前的参数值 WindowManager.LayoutParams p = window.getAttributes(); // 获取对话框当前的参数值
p.width = width; p.width = width;
window.setAttributes(p); window.setAttributes(p);
...@@ -79,7 +79,7 @@ public abstract class DialogUtils { ...@@ -79,7 +79,7 @@ public abstract class DialogUtils {
public DialogUtils setHeight(int height) { public DialogUtils setHeight(int height) {
if (dialog != null) { if (dialog != null) {
Window window = dialog.getWindow(); Window window = dialog.getWindow();
if(window != null) { if (window != null) {
WindowManager.LayoutParams p = window.getAttributes(); // 获取对话框当前的参数值 WindowManager.LayoutParams p = window.getAttributes(); // 获取对话框当前的参数值
p.height = height; p.height = height;
window.setAttributes(p); window.setAttributes(p);
...@@ -99,7 +99,7 @@ public abstract class DialogUtils { ...@@ -99,7 +99,7 @@ public abstract class DialogUtils {
return this; return this;
} }
public DialogUtils setBackgroundResource(int resid){ public DialogUtils setBackgroundResource(int resid) {
if (dialog != null) { if (dialog != null) {
Window window = dialog.getWindow(); Window window = dialog.getWindow();
if (window != null) { if (window != null) {
...@@ -220,9 +220,9 @@ public abstract class DialogUtils { ...@@ -220,9 +220,9 @@ public abstract class DialogUtils {
mConvertView = view; mConvertView = view;
} }
public void clearAll(){ public void clearAll() {
context = null; context = null;
if(mViews != null) { if (mViews != null) {
mViews.clear(); mViews.clear();
} }
mConvertView = null; mConvertView = null;
...@@ -368,4 +368,31 @@ public abstract class DialogUtils { ...@@ -368,4 +368,31 @@ public abstract class DialogUtils {
} }
} }
public interface onPopupSureClickListener {
void onClick(int select);
}
public static void showSelectPopop(Context context, List<String> items, String title, int defaultSelect, onPopupSureClickListener onClickListener) {
new DialogUtils(context, R.layout.dialog_select_print_device) {
@Override
public void initLayout(ViewHepler hepler, Dialog dialog) {
hepler.setText(R.id.tv_title, title);
WheelView wheelView = hepler.getView(R.id.wv_model);
wheelView.setSeletion(defaultSelect);
wheelView.setItems(items);
hepler.getView(R.id.btn_cancel).setOnClickListener(v -> dialog.dismiss());
hepler.getView(R.id.btn_confirm).setOnClickListener(v -> {
dialog.dismiss();
if (onClickListener != null)
onClickListener.onClick(wheelView.getSeletedIndex());
});
}
}
.setWidth(WindowManager.LayoutParams.MATCH_PARENT)
.setGravity(Gravity.BOTTOM)
.show();
}
} }
...@@ -42,12 +42,33 @@ public class PrinterDeviceBean implements Serializable { ...@@ -42,12 +42,33 @@ public class PrinterDeviceBean implements Serializable {
*/ */
private Long flyPrinterDeviceId2; private Long flyPrinterDeviceId2;
private int foodIsBold;//食品是否加粗 1是 2否
private String foodFont;
private int foodIsItalic;//食品是否斜體 1是 2否
private int modifierIsBold;//細項是否加粗 1是 2否
private String modifierFont;//細項字號
private int modifierIsItalic;//細項是否斜體 1是 2否
private int numberIsFlip;//數量大於1顔色是否翻轉 1是 2否
@Generated(hash = 626885316) @Generated(hash = 626885316)
public PrinterDeviceBean() { public PrinterDeviceBean() {
} }
@Generated(hash = 1228354346) public PrinterDeviceBean(String ip, Integer port, String paperSpecification) {
public PrinterDeviceBean(Long id, Long dbid, String name, Integer restaurantId, String ip, Long uid, Integer port, Integer type, Long printerModelId, String paperSpecification, String printerName, String model, String noteContent, Long printerDeviceDefaultId, Long flyPrinterDeviceId, Long flyPrinterDeviceId2) { this.ip = ip;
this.port = port;
this.paperSpecification = paperSpecification;
}
@Generated(hash = 1904986682)
public PrinterDeviceBean(Long id, Long dbid, String name, Integer restaurantId, String ip, Long uid, Integer port, Integer type, Long printerModelId, String paperSpecification, String printerName, String model, String noteContent, Long printerDeviceDefaultId, Long flyPrinterDeviceId, Long flyPrinterDeviceId2, int foodIsBold, String foodFont, int foodIsItalic, int modifierIsBold, String modifierFont, int modifierIsItalic,
int numberIsFlip) {
this.id = id; this.id = id;
this.dbid = dbid; this.dbid = dbid;
this.name = name; this.name = name;
...@@ -64,13 +85,13 @@ public class PrinterDeviceBean implements Serializable { ...@@ -64,13 +85,13 @@ public class PrinterDeviceBean implements Serializable {
this.printerDeviceDefaultId = printerDeviceDefaultId; this.printerDeviceDefaultId = printerDeviceDefaultId;
this.flyPrinterDeviceId = flyPrinterDeviceId; this.flyPrinterDeviceId = flyPrinterDeviceId;
this.flyPrinterDeviceId2 = flyPrinterDeviceId2; this.flyPrinterDeviceId2 = flyPrinterDeviceId2;
} this.foodIsBold = foodIsBold;
this.foodFont = foodFont;
this.foodIsItalic = foodIsItalic;
public PrinterDeviceBean(String ip, Integer port, String paperSpecification) { this.modifierIsBold = modifierIsBold;
this.ip = ip; this.modifierFont = modifierFont;
this.port = port; this.modifierIsItalic = modifierIsItalic;
this.paperSpecification = paperSpecification; this.numberIsFlip = numberIsFlip;
} }
public Long getId() { public Long getId() {
...@@ -203,4 +224,64 @@ public class PrinterDeviceBean implements Serializable { ...@@ -203,4 +224,64 @@ public class PrinterDeviceBean implements Serializable {
public void setPrinterDeviceDefaultId(Long printerDeviceDefaultId) { public void setPrinterDeviceDefaultId(Long printerDeviceDefaultId) {
this.printerDeviceDefaultId = printerDeviceDefaultId; this.printerDeviceDefaultId = printerDeviceDefaultId;
} }
public static long getSerialVersionUID() {
return serialVersionUID;
}
public int getFoodIsBold() {
return foodIsBold;
}
public void setFoodIsBold(int foodIsBold) {
this.foodIsBold = foodIsBold;
}
public String getFoodFont() {
return foodFont;
}
public void setFoodFont(String foodFont) {
this.foodFont = foodFont;
}
public int getFoodIsItalic() {
return foodIsItalic;
}
public void setFoodIsItalic(int foodIsItalic) {
this.foodIsItalic = foodIsItalic;
}
public int getModifierIsBold() {
return modifierIsBold;
}
public void setModifierIsBold(int modifierIsBold) {
this.modifierIsBold = modifierIsBold;
}
public String getModifierFont() {
return modifierFont;
}
public void setModifierFont(String modifierFont) {
this.modifierFont = modifierFont;
}
public int getModifierIsItalic() {
return modifierIsItalic;
}
public void setModifierIsItalic(int modifierIsItalic) {
this.modifierIsItalic = modifierIsItalic;
}
public int getNumberIsFlip() {
return numberIsFlip;
}
public void setNumberIsFlip(int numberIsFlip) {
this.numberIsFlip = numberIsFlip;
}
} }
...@@ -28,10 +28,11 @@ public class DaoMaster extends AbstractDaoMaster { ...@@ -28,10 +28,11 @@ public class DaoMaster extends AbstractDaoMaster {
FoodComboDao.createTable(db, ifNotExists); FoodComboDao.createTable(db, ifNotExists);
FoodModifierDao.createTable(db, ifNotExists); FoodModifierDao.createTable(db, ifNotExists);
FunctionDao.createTable(db, ifNotExists); FunctionDao.createTable(db, ifNotExists);
LanguageDao.createTable(db, ifNotExists);
ModifierDao.createTable(db, ifNotExists); ModifierDao.createTable(db, ifNotExists);
PrinterDeviceBeanDao.createTable(db, ifNotExists); PrinterDeviceBeanDao.createTable(db, ifNotExists);
PrintModelBeanDao.createTable(db, ifNotExists); PrintModelBeanDao.createTable(db, ifNotExists);
LanguageDao.createTable(db, ifNotExists);
PrintCurrencyBeanDao.createTable(db, ifNotExists);
} }
/** Drops underlying database table using DAOs. */ /** Drops underlying database table using DAOs. */
...@@ -43,10 +44,11 @@ public class DaoMaster extends AbstractDaoMaster { ...@@ -43,10 +44,11 @@ public class DaoMaster extends AbstractDaoMaster {
FoodComboDao.dropTable(db, ifExists); FoodComboDao.dropTable(db, ifExists);
FoodModifierDao.dropTable(db, ifExists); FoodModifierDao.dropTable(db, ifExists);
FunctionDao.dropTable(db, ifExists); FunctionDao.dropTable(db, ifExists);
LanguageDao.dropTable(db, ifExists);
ModifierDao.dropTable(db, ifExists); ModifierDao.dropTable(db, ifExists);
PrinterDeviceBeanDao.dropTable(db, ifExists); PrinterDeviceBeanDao.dropTable(db, ifExists);
PrintModelBeanDao.dropTable(db, ifExists); PrintModelBeanDao.dropTable(db, ifExists);
LanguageDao.dropTable(db, ifExists);
PrintCurrencyBeanDao.dropTable(db, ifExists);
} }
/** /**
...@@ -72,10 +74,11 @@ public class DaoMaster extends AbstractDaoMaster { ...@@ -72,10 +74,11 @@ public class DaoMaster extends AbstractDaoMaster {
registerDaoClass(FoodComboDao.class); registerDaoClass(FoodComboDao.class);
registerDaoClass(FoodModifierDao.class); registerDaoClass(FoodModifierDao.class);
registerDaoClass(FunctionDao.class); registerDaoClass(FunctionDao.class);
registerDaoClass(LanguageDao.class);
registerDaoClass(ModifierDao.class); registerDaoClass(ModifierDao.class);
registerDaoClass(PrinterDeviceBeanDao.class); registerDaoClass(PrinterDeviceBeanDao.class);
registerDaoClass(PrintModelBeanDao.class); registerDaoClass(PrintModelBeanDao.class);
registerDaoClass(LanguageDao.class);
registerDaoClass(PrintCurrencyBeanDao.class);
} }
public DaoSession newSession() { public DaoSession newSession() {
......
...@@ -15,10 +15,11 @@ import com.gingersoft.gsa.cloud.database.bean.Food; ...@@ -15,10 +15,11 @@ import com.gingersoft.gsa.cloud.database.bean.Food;
import com.gingersoft.gsa.cloud.database.bean.FoodCombo; import com.gingersoft.gsa.cloud.database.bean.FoodCombo;
import com.gingersoft.gsa.cloud.database.bean.FoodModifier; import com.gingersoft.gsa.cloud.database.bean.FoodModifier;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.database.bean.Language;
import com.gingersoft.gsa.cloud.database.bean.Modifier; import com.gingersoft.gsa.cloud.database.bean.Modifier;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.bean.PrintModelBean; import com.gingersoft.gsa.cloud.database.bean.PrintModelBean;
import com.gingersoft.gsa.cloud.database.bean.Language;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.greendao.ComboItemDao; import com.gingersoft.gsa.cloud.database.greendao.ComboItemDao;
import com.gingersoft.gsa.cloud.database.greendao.DiscountDao; import com.gingersoft.gsa.cloud.database.greendao.DiscountDao;
...@@ -27,10 +28,11 @@ import com.gingersoft.gsa.cloud.database.greendao.FoodDao; ...@@ -27,10 +28,11 @@ import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodComboDao; import com.gingersoft.gsa.cloud.database.greendao.FoodComboDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodModifierDao; import com.gingersoft.gsa.cloud.database.greendao.FoodModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.FunctionDao; import com.gingersoft.gsa.cloud.database.greendao.FunctionDao;
import com.gingersoft.gsa.cloud.database.greendao.LanguageDao;
import com.gingersoft.gsa.cloud.database.greendao.ModifierDao; import com.gingersoft.gsa.cloud.database.greendao.ModifierDao;
import com.gingersoft.gsa.cloud.database.greendao.PrinterDeviceBeanDao; import com.gingersoft.gsa.cloud.database.greendao.PrinterDeviceBeanDao;
import com.gingersoft.gsa.cloud.database.greendao.PrintModelBeanDao; import com.gingersoft.gsa.cloud.database.greendao.PrintModelBeanDao;
import com.gingersoft.gsa.cloud.database.greendao.LanguageDao;
import com.gingersoft.gsa.cloud.database.greendao.PrintCurrencyBeanDao;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
...@@ -48,10 +50,11 @@ public class DaoSession extends AbstractDaoSession { ...@@ -48,10 +50,11 @@ public class DaoSession extends AbstractDaoSession {
private final DaoConfig foodComboDaoConfig; private final DaoConfig foodComboDaoConfig;
private final DaoConfig foodModifierDaoConfig; private final DaoConfig foodModifierDaoConfig;
private final DaoConfig functionDaoConfig; private final DaoConfig functionDaoConfig;
private final DaoConfig languageDaoConfig;
private final DaoConfig modifierDaoConfig; private final DaoConfig modifierDaoConfig;
private final DaoConfig printerDeviceBeanDaoConfig; private final DaoConfig printerDeviceBeanDaoConfig;
private final DaoConfig printModelBeanDaoConfig; private final DaoConfig printModelBeanDaoConfig;
private final DaoConfig languageDaoConfig;
private final DaoConfig printCurrencyBeanDaoConfig;
private final ComboItemDao comboItemDao; private final ComboItemDao comboItemDao;
private final DiscountDao discountDao; private final DiscountDao discountDao;
...@@ -60,10 +63,11 @@ public class DaoSession extends AbstractDaoSession { ...@@ -60,10 +63,11 @@ public class DaoSession extends AbstractDaoSession {
private final FoodComboDao foodComboDao; private final FoodComboDao foodComboDao;
private final FoodModifierDao foodModifierDao; private final FoodModifierDao foodModifierDao;
private final FunctionDao functionDao; private final FunctionDao functionDao;
private final LanguageDao languageDao;
private final ModifierDao modifierDao; private final ModifierDao modifierDao;
private final PrinterDeviceBeanDao printerDeviceBeanDao; private final PrinterDeviceBeanDao printerDeviceBeanDao;
private final PrintModelBeanDao printModelBeanDao; private final PrintModelBeanDao printModelBeanDao;
private final LanguageDao languageDao;
private final PrintCurrencyBeanDao printCurrencyBeanDao;
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) { daoConfigMap) {
...@@ -90,9 +94,6 @@ public class DaoSession extends AbstractDaoSession { ...@@ -90,9 +94,6 @@ public class DaoSession extends AbstractDaoSession {
functionDaoConfig = daoConfigMap.get(FunctionDao.class).clone(); functionDaoConfig = daoConfigMap.get(FunctionDao.class).clone();
functionDaoConfig.initIdentityScope(type); functionDaoConfig.initIdentityScope(type);
languageDaoConfig = daoConfigMap.get(LanguageDao.class).clone();
languageDaoConfig.initIdentityScope(type);
modifierDaoConfig = daoConfigMap.get(ModifierDao.class).clone(); modifierDaoConfig = daoConfigMap.get(ModifierDao.class).clone();
modifierDaoConfig.initIdentityScope(type); modifierDaoConfig.initIdentityScope(type);
...@@ -102,6 +103,12 @@ public class DaoSession extends AbstractDaoSession { ...@@ -102,6 +103,12 @@ public class DaoSession extends AbstractDaoSession {
printModelBeanDaoConfig = daoConfigMap.get(PrintModelBeanDao.class).clone(); printModelBeanDaoConfig = daoConfigMap.get(PrintModelBeanDao.class).clone();
printModelBeanDaoConfig.initIdentityScope(type); printModelBeanDaoConfig.initIdentityScope(type);
languageDaoConfig = daoConfigMap.get(LanguageDao.class).clone();
languageDaoConfig.initIdentityScope(type);
printCurrencyBeanDaoConfig = daoConfigMap.get(PrintCurrencyBeanDao.class).clone();
printCurrencyBeanDaoConfig.initIdentityScope(type);
comboItemDao = new ComboItemDao(comboItemDaoConfig, this); comboItemDao = new ComboItemDao(comboItemDaoConfig, this);
discountDao = new DiscountDao(discountDaoConfig, this); discountDao = new DiscountDao(discountDaoConfig, this);
expandInfoDao = new ExpandInfoDao(expandInfoDaoConfig, this); expandInfoDao = new ExpandInfoDao(expandInfoDaoConfig, this);
...@@ -109,10 +116,11 @@ public class DaoSession extends AbstractDaoSession { ...@@ -109,10 +116,11 @@ public class DaoSession extends AbstractDaoSession {
foodComboDao = new FoodComboDao(foodComboDaoConfig, this); foodComboDao = new FoodComboDao(foodComboDaoConfig, this);
foodModifierDao = new FoodModifierDao(foodModifierDaoConfig, this); foodModifierDao = new FoodModifierDao(foodModifierDaoConfig, this);
functionDao = new FunctionDao(functionDaoConfig, this); functionDao = new FunctionDao(functionDaoConfig, this);
languageDao = new LanguageDao(languageDaoConfig, this);
modifierDao = new ModifierDao(modifierDaoConfig, this); modifierDao = new ModifierDao(modifierDaoConfig, this);
printerDeviceBeanDao = new PrinterDeviceBeanDao(printerDeviceBeanDaoConfig, this); printerDeviceBeanDao = new PrinterDeviceBeanDao(printerDeviceBeanDaoConfig, this);
printModelBeanDao = new PrintModelBeanDao(printModelBeanDaoConfig, this); printModelBeanDao = new PrintModelBeanDao(printModelBeanDaoConfig, this);
languageDao = new LanguageDao(languageDaoConfig, this);
printCurrencyBeanDao = new PrintCurrencyBeanDao(printCurrencyBeanDaoConfig, this);
registerDao(ComboItem.class, comboItemDao); registerDao(ComboItem.class, comboItemDao);
registerDao(Discount.class, discountDao); registerDao(Discount.class, discountDao);
...@@ -121,10 +129,11 @@ public class DaoSession extends AbstractDaoSession { ...@@ -121,10 +129,11 @@ public class DaoSession extends AbstractDaoSession {
registerDao(FoodCombo.class, foodComboDao); registerDao(FoodCombo.class, foodComboDao);
registerDao(FoodModifier.class, foodModifierDao); registerDao(FoodModifier.class, foodModifierDao);
registerDao(Function.class, functionDao); registerDao(Function.class, functionDao);
registerDao(Language.class, languageDao);
registerDao(Modifier.class, modifierDao); registerDao(Modifier.class, modifierDao);
registerDao(PrinterDeviceBean.class, printerDeviceBeanDao); registerDao(PrinterDeviceBean.class, printerDeviceBeanDao);
registerDao(PrintModelBean.class, printModelBeanDao); registerDao(PrintModelBean.class, printModelBeanDao);
registerDao(Language.class, languageDao);
registerDao(PrintCurrencyBean.class, printCurrencyBeanDao);
} }
public void clear() { public void clear() {
...@@ -135,10 +144,11 @@ public class DaoSession extends AbstractDaoSession { ...@@ -135,10 +144,11 @@ public class DaoSession extends AbstractDaoSession {
foodComboDaoConfig.clearIdentityScope(); foodComboDaoConfig.clearIdentityScope();
foodModifierDaoConfig.clearIdentityScope(); foodModifierDaoConfig.clearIdentityScope();
functionDaoConfig.clearIdentityScope(); functionDaoConfig.clearIdentityScope();
languageDaoConfig.clearIdentityScope();
modifierDaoConfig.clearIdentityScope(); modifierDaoConfig.clearIdentityScope();
printerDeviceBeanDaoConfig.clearIdentityScope(); printerDeviceBeanDaoConfig.clearIdentityScope();
printModelBeanDaoConfig.clearIdentityScope(); printModelBeanDaoConfig.clearIdentityScope();
languageDaoConfig.clearIdentityScope();
printCurrencyBeanDaoConfig.clearIdentityScope();
} }
public ComboItemDao getComboItemDao() { public ComboItemDao getComboItemDao() {
...@@ -169,10 +179,6 @@ public class DaoSession extends AbstractDaoSession { ...@@ -169,10 +179,6 @@ public class DaoSession extends AbstractDaoSession {
return functionDao; return functionDao;
} }
public LanguageDao getLanguageDao() {
return languageDao;
}
public ModifierDao getModifierDao() { public ModifierDao getModifierDao() {
return modifierDao; return modifierDao;
} }
...@@ -185,4 +191,12 @@ public class DaoSession extends AbstractDaoSession { ...@@ -185,4 +191,12 @@ public class DaoSession extends AbstractDaoSession {
return printModelBeanDao; return printModelBeanDao;
} }
public LanguageDao getLanguageDao() {
return languageDao;
}
public PrintCurrencyBeanDao getPrintCurrencyBeanDao() {
return printCurrencyBeanDao;
}
} }
...@@ -40,6 +40,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -40,6 +40,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
public final static Property PrinterDeviceDefaultId = new Property(13, Long.class, "printerDeviceDefaultId", false, "PRINTER_DEVICE_DEFAULT_ID"); public final static Property PrinterDeviceDefaultId = new Property(13, Long.class, "printerDeviceDefaultId", false, "PRINTER_DEVICE_DEFAULT_ID");
public final static Property FlyPrinterDeviceId = new Property(14, Long.class, "flyPrinterDeviceId", false, "FLY_PRINTER_DEVICE_ID"); public final static Property FlyPrinterDeviceId = new Property(14, Long.class, "flyPrinterDeviceId", false, "FLY_PRINTER_DEVICE_ID");
public final static Property FlyPrinterDeviceId2 = new Property(15, Long.class, "flyPrinterDeviceId2", false, "FLY_PRINTER_DEVICE_ID2"); public final static Property FlyPrinterDeviceId2 = new Property(15, Long.class, "flyPrinterDeviceId2", false, "FLY_PRINTER_DEVICE_ID2");
public final static Property FoodIsBold = new Property(16, int.class, "foodIsBold", false, "FOOD_IS_BOLD");
public final static Property FoodFont = new Property(17, String.class, "foodFont", false, "FOOD_FONT");
public final static Property FoodIsItalic = new Property(18, int.class, "foodIsItalic", false, "FOOD_IS_ITALIC");
public final static Property ModifierIsBold = new Property(19, int.class, "modifierIsBold", false, "MODIFIER_IS_BOLD");
public final static Property ModifierFont = new Property(20, String.class, "modifierFont", false, "MODIFIER_FONT");
public final static Property ModifierIsItalic = new Property(21, int.class, "modifierIsItalic", false, "MODIFIER_IS_ITALIC");
public final static Property NumberIsFlip = new Property(22, int.class, "numberIsFlip", false, "NUMBER_IS_FLIP");
} }
...@@ -70,7 +77,14 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -70,7 +77,14 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
"\"NOTE_CONTENT\" TEXT," + // 12: noteContent "\"NOTE_CONTENT\" TEXT," + // 12: noteContent
"\"PRINTER_DEVICE_DEFAULT_ID\" INTEGER," + // 13: printerDeviceDefaultId "\"PRINTER_DEVICE_DEFAULT_ID\" INTEGER," + // 13: printerDeviceDefaultId
"\"FLY_PRINTER_DEVICE_ID\" INTEGER," + // 14: flyPrinterDeviceId "\"FLY_PRINTER_DEVICE_ID\" INTEGER," + // 14: flyPrinterDeviceId
"\"FLY_PRINTER_DEVICE_ID2\" INTEGER);"); // 15: flyPrinterDeviceId2 "\"FLY_PRINTER_DEVICE_ID2\" INTEGER," + // 15: flyPrinterDeviceId2
"\"FOOD_IS_BOLD\" INTEGER NOT NULL ," + // 16: foodIsBold
"\"FOOD_FONT\" TEXT," + // 17: foodFont
"\"FOOD_IS_ITALIC\" INTEGER NOT NULL ," + // 18: foodIsItalic
"\"MODIFIER_IS_BOLD\" INTEGER NOT NULL ," + // 19: modifierIsBold
"\"MODIFIER_FONT\" TEXT," + // 20: modifierFont
"\"MODIFIER_IS_ITALIC\" INTEGER NOT NULL ," + // 21: modifierIsItalic
"\"NUMBER_IS_FLIP\" INTEGER NOT NULL );"); // 22: numberIsFlip
} }
/** Drops the underlying database table. */ /** Drops the underlying database table. */
...@@ -162,6 +176,21 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -162,6 +176,21 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if (flyPrinterDeviceId2 != null) { if (flyPrinterDeviceId2 != null) {
stmt.bindLong(16, flyPrinterDeviceId2); stmt.bindLong(16, flyPrinterDeviceId2);
} }
stmt.bindLong(17, entity.getFoodIsBold());
String foodFont = entity.getFoodFont();
if (foodFont != null) {
stmt.bindString(18, foodFont);
}
stmt.bindLong(19, entity.getFoodIsItalic());
stmt.bindLong(20, entity.getModifierIsBold());
String modifierFont = entity.getModifierFont();
if (modifierFont != null) {
stmt.bindString(21, modifierFont);
}
stmt.bindLong(22, entity.getModifierIsItalic());
stmt.bindLong(23, entity.getNumberIsFlip());
} }
@Override @Override
...@@ -247,6 +276,21 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -247,6 +276,21 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
if (flyPrinterDeviceId2 != null) { if (flyPrinterDeviceId2 != null) {
stmt.bindLong(16, flyPrinterDeviceId2); stmt.bindLong(16, flyPrinterDeviceId2);
} }
stmt.bindLong(17, entity.getFoodIsBold());
String foodFont = entity.getFoodFont();
if (foodFont != null) {
stmt.bindString(18, foodFont);
}
stmt.bindLong(19, entity.getFoodIsItalic());
stmt.bindLong(20, entity.getModifierIsBold());
String modifierFont = entity.getModifierFont();
if (modifierFont != null) {
stmt.bindString(21, modifierFont);
}
stmt.bindLong(22, entity.getModifierIsItalic());
stmt.bindLong(23, entity.getNumberIsFlip());
} }
@Override @Override
...@@ -272,7 +316,14 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -272,7 +316,14 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // noteContent cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // noteContent
cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13), // printerDeviceDefaultId cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13), // printerDeviceDefaultId
cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14), // flyPrinterDeviceId cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14), // flyPrinterDeviceId
cursor.isNull(offset + 15) ? null : cursor.getLong(offset + 15) // flyPrinterDeviceId2 cursor.isNull(offset + 15) ? null : cursor.getLong(offset + 15), // flyPrinterDeviceId2
cursor.getInt(offset + 16), // foodIsBold
cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // foodFont
cursor.getInt(offset + 18), // foodIsItalic
cursor.getInt(offset + 19), // modifierIsBold
cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // modifierFont
cursor.getInt(offset + 21), // modifierIsItalic
cursor.getInt(offset + 22) // numberIsFlip
); );
return entity; return entity;
} }
...@@ -295,6 +346,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> { ...@@ -295,6 +346,13 @@ public class PrinterDeviceBeanDao extends AbstractDao<PrinterDeviceBean, Long> {
entity.setPrinterDeviceDefaultId(cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13)); entity.setPrinterDeviceDefaultId(cursor.isNull(offset + 13) ? null : cursor.getLong(offset + 13));
entity.setFlyPrinterDeviceId(cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14)); entity.setFlyPrinterDeviceId(cursor.isNull(offset + 14) ? null : cursor.getLong(offset + 14));
entity.setFlyPrinterDeviceId2(cursor.isNull(offset + 15) ? null : cursor.getLong(offset + 15)); entity.setFlyPrinterDeviceId2(cursor.isNull(offset + 15) ? null : cursor.getLong(offset + 15));
entity.setFoodIsBold(cursor.getInt(offset + 16));
entity.setFoodFont(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
entity.setFoodIsItalic(cursor.getInt(offset + 18));
entity.setModifierIsBold(cursor.getInt(offset + 19));
entity.setModifierFont(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
entity.setModifierIsItalic(cursor.getInt(offset + 21));
entity.setNumberIsFlip(cursor.getInt(offset + 22));
} }
@Override @Override
......
package com.gingersoft.gsa.cloud.database.utils;//package com.gingersoft.gsa.cloud.database.utils;
import android.content.Context;
import android.util.Log;
import com.gingersoft.gsa.cloud.database.DaoManager;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.greendao.PrintCurrencyBeanDao;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.List;
/**
* Created by Wyh on 2020/1/17.
*/
public class PrintCurrencyDaoUtils {
private static final String TAG = PrintCurrencyDaoUtils.class.getSimpleName();
private DaoManager mManager;
public PrintCurrencyDaoUtils(Context context) {
mManager = DaoManager.getInstance();
mManager.init(context);
}
/**
* 完成PrintCurrencyBean记录的插入,如果表未创建,先创建PrintCurrencyBean表
*
* @return
*/
public boolean insertPrintCurrencyBean(PrintCurrencyBean printerDevice) {
boolean flag = false;
flag = mManager.getDaoSession().getPrintCurrencyBeanDao().insert(printerDevice) == -1 ? false : true;
Log.i(TAG, "insert printerDevice :" + flag + "-->" + printerDevice.toString());
return flag;
}
/**
* 插入多条数据,在子线程操作
*
* @param printerDeviceList
* @return
*/
public boolean insertMultPrintCurrencyBean(final List<PrintCurrencyBean> printerDeviceList) {
boolean flag = false;
try {
mManager.getDaoSession().runInTx(new Runnable() {
@Override
public void run() {
for (PrintCurrencyBean PrintCurrencyBean : printerDeviceList) {
mManager.getDaoSession().insertOrReplace(PrintCurrencyBean);
}
}
});
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 修改一条数据
*
* @param printerDevice
* @return
*/
public boolean updatePrintCurrencyBean(PrintCurrencyBean printerDevice) {
boolean flag = false;
try {
mManager.getDaoSession().update(printerDevice);
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 删除单条记录
*
* @param printerDevice
* @return
*/
public boolean deletePrintCurrencyBean(PrintCurrencyBean printerDevice) {
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().delete(printerDevice);
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 删除所有记录
*
* @return
*/
public boolean deleteAll() {
boolean flag = false;
try {
//按照id删除
mManager.getDaoSession().deleteAll(PrintCurrencyBean.class);
flag = true;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 查询所有记录
*
* @return
*/
public List<PrintCurrencyBean> queryAllPrintCurrencyBean() {
return mManager.getDaoSession().loadAll(PrintCurrencyBean.class);
}
/**
* 根据主键id查询记录
*
* @param key
* @return
*/
public PrintCurrencyBean queryPrintCurrencyBeanById(long key) {
return mManager.getDaoSession().load(PrintCurrencyBean.class, key);
}
/**
* 使用native sql进行查询操作
*/
public List<PrintCurrencyBean> queryPrintCurrencyBeanByNativeSql(String sql, String[] conditions) {
return mManager.getDaoSession().queryRaw(PrintCurrencyBean.class, sql, conditions);
}
/**
* 使用queryBuilder进行查询
*
* @return
*/
public List<PrintCurrencyBean> queryPrintCurrencyBeanByQueryBuilder(long PrintCurrencyBeanId) {
QueryBuilder<PrintCurrencyBean> queryBuilder = mManager.getDaoSession().queryBuilder(PrintCurrencyBean.class);
return queryBuilder.where(PrintCurrencyBeanDao.Properties.Id.eq(PrintCurrencyBeanId)).list();
}
public void closeConnection() {
mManager.closeConnection();
}
}
package com.joe.print.mvp.ui.view; package com.gingersoft.gsa.cloud.ui.view;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/tv_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
...@@ -14,7 +15,7 @@ ...@@ -14,7 +15,7 @@
android:textColor="@color/theme_333_color" android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16" /> android:textSize="@dimen/dp_16" />
<com.joe.print.mvp.ui.view.WheelView <com.gingersoft.gsa.cloud.ui.view.WheelView
android:id="@+id/wv_model" android:id="@+id/wv_model"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
......
...@@ -47,54 +47,51 @@ ...@@ -47,54 +47,51 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_restaurant_name" /> app:layout_constraintTop_toBottomOf="@id/tv_restaurant_name" />
<LinearLayout
<TextView android:id="@+id/layout_table_name"
android:id="@+id/tv_dining_table_text" android:layout_width="match_parent"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:orientation="horizontal"
android:text="餐檯:"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_restaurant_name" /> app:layout_constraintTop_toBottomOf="@id/line_restaurant_name">
<TextView <TextView
android:id="@+id/tv_dining_table_number" android:id="@+id/tv_dining_table_text"
style="@style/Print_text_style" style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_5" android:text="餐檯:" />
app:layout_constraintBottom_toBottomOf="@id/tv_dining_table_text"
app:layout_constraintLeft_toRightOf="@id/tv_dining_table_text" <TextView
app:layout_constraintTop_toTopOf="@id/tv_dining_table_text" /> android:id="@+id/tv_dining_table_number"
style="@style/Print_text_style"
android:layout_width="0dp"
<TextView android:layout_weight="1"
android:id="@+id/tv_people_text" android:layout_height="wrap_content"
style="@style/Print_text_style" android:layout_gravity="center_horizontal"
android:layout_width="wrap_content" android:layout_marginLeft="@dimen/dp_5" />
android:layout_height="wrap_content"
android:gravity="right" <TextView
android:text="人數:" android:id="@+id/tv_people_text"
app:layout_constraintHorizontal_bias="0.3" style="@style/Print_text_style"
app:layout_constraintRight_toRightOf="parent" android:layout_width="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/tv_dining_table_text" android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@id/tv_dining_table_number" android:text="人數:" />
app:layout_constraintTop_toTopOf="@id/tv_dining_table_text" />
<TextView
<TextView android:id="@+id/tv_people"
android:id="@+id/tv_people" style="@style/Print_text_style"
style="@style/Print_text_style" android:layout_width="0dp"
android:layout_width="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_5" app:layout_constraintBottom_toBottomOf="@id/tv_people_text"
app:layout_constraintBottom_toBottomOf="@id/tv_people_text" app:layout_constraintLeft_toRightOf="@id/tv_people_text"
app:layout_constraintLeft_toRightOf="@id/tv_people_text" app:layout_constraintTop_toTopOf="@id/tv_people_text" />
app:layout_constraintTop_toTopOf="@id/tv_people_text" />
</LinearLayout>
<TextView <TextView
android:id="@+id/tv_order_number_text" android:id="@+id/tv_order_number_text"
...@@ -104,7 +101,7 @@ ...@@ -104,7 +101,7 @@
android:text="單號:" android:text="單號:"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_dining_table_text" /> app:layout_constraintTop_toBottomOf="@id/layout_table_name" />
<TextView <TextView
android:id="@+id/tv_order_num" android:id="@+id/tv_order_num"
...@@ -156,7 +153,6 @@ ...@@ -156,7 +153,6 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:maxLines="1"
android:text="——————————————————————————————————————————————————" android:text="——————————————————————————————————————————————————"
app:layout_constraintHorizontal_weight="0.6" app:layout_constraintHorizontal_weight="0.6"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
...@@ -178,7 +174,6 @@ ...@@ -178,7 +174,6 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:maxLines="1"
android:text="——————————————————————————————————————————————————" android:text="——————————————————————————————————————————————————"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/rv_bill_amount" app:layout_constraintTop_toBottomOf="@id/rv_bill_amount"
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:gravity="center" android:gravity="center"
android:text="gs1" android:text="gs1"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:gravity="center" android:gravity="center"
android:text="yan" android:text="yan"
app:layout_constraintTop_toBottomOf="@id/tv_brand_name"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" /> app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_brand_name" />
<TextView <TextView
android:id="@+id/tv_print_bill_order_num" android:id="@+id/tv_print_bill_order_num"
...@@ -46,104 +46,110 @@ ...@@ -46,104 +46,110 @@
<TextView <TextView
android:id="@+id/line_restaurant_name" android:id="@+id/line_restaurant_name"
style="@style/Print_text_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10" android:layout_marginTop="@dimen/dp_10"
android:maxLines="1" android:maxLines="1"
style="@style/Print_text_style"
android:text="——————————————————————————————————————————————————" android:text="——————————————————————————————————————————————————"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_print_bill_order_num" /> app:layout_constraintTop_toBottomOf="@id/tv_print_bill_order_num" />
<LinearLayout
<TextView android:id="@+id/layout_dining_table"
android:id="@+id/tv_dining_table_text" android:layout_width="match_parent"
android:layout_width="wrap_content"
style="@style/Print_text_style"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:orientation="horizontal"
android:text="餐檯:"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/line_restaurant_name" /> app:layout_constraintTop_toBottomOf="@id/line_restaurant_name">
<TextView <TextView
android:id="@+id/tv_dining_table_number" android:id="@+id/tv_dining_table_text"
android:layout_width="wrap_content" style="@style/Print_text_style"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5" android:layout_gravity="center_horizontal"
style="@style/Print_text_style" android:text="餐檯:" />
app:layout_constraintBottom_toBottomOf="@id/tv_dining_table_text"
app:layout_constraintLeft_toRightOf="@id/tv_dining_table_text"
app:layout_constraintTop_toTopOf="@id/tv_dining_table_text" />
<TextView
android:id="@+id/tv_dining_table_number"
style="@style/Print_text_style"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_5"
app:layout_constraintBottom_toBottomOf="@id/tv_dining_table_text"
app:layout_constraintLeft_toRightOf="@id/tv_dining_table_text"
app:layout_constraintTop_toTopOf="@id/tv_dining_table_text" />
<TextView <TextView
android:id="@+id/tv_people_text" android:id="@+id/tv_people_text"
android:layout_width="wrap_content" style="@style/Print_text_style"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center" android:layout_height="wrap_content"
android:gravity="right" android:gravity="right"
android:text="人數:" android:text="人數:"
style="@style/Print_text_style" app:layout_constraintBottom_toBottomOf="@id/tv_dining_table_text"
app:layout_constraintBottom_toBottomOf="@id/tv_dining_table_text" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="@id/tv_dining_table_text" />
app:layout_constraintTop_toTopOf="@id/tv_dining_table_text" />
<TextView <TextView
android:id="@+id/tv_people" android:id="@+id/tv_people"
android:layout_width="wrap_content" style="@style/Print_text_style"
android:layout_height="wrap_content" android:layout_width="0dp"
android:layout_gravity="center_horizontal" android:layout_weight="1"
android:layout_marginLeft="@dimen/dp_5" android:layout_height="wrap_content"
style="@style/Print_text_style" android:layout_marginLeft="@dimen/dp_5"
app:layout_constraintBottom_toBottomOf="@id/tv_people_text" app:layout_constraintBottom_toBottomOf="@id/tv_people_text"
app:layout_constraintLeft_toRightOf="@id/tv_people_text" app:layout_constraintLeft_toRightOf="@id/tv_people_text"
app:layout_constraintTop_toTopOf="@id/tv_people_text" /> app:layout_constraintTop_toTopOf="@id/tv_people_text" />
</LinearLayout>
<TextView <TextView
android:id="@+id/tv_order_number_text" android:id="@+id/tv_order_number_text"
style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="單號:" android:text="單號:"
style="@style/Print_text_style"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_dining_table_text" /> app:layout_constraintTop_toBottomOf="@id/layout_dining_table" />
<TextView <TextView
android:id="@+id/tv_order_num" android:id="@+id/tv_order_num"
style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Print_text_style"
app:layout_constraintBottom_toBottomOf="@id/tv_order_number_text" app:layout_constraintBottom_toBottomOf="@id/tv_order_number_text"
app:layout_constraintLeft_toRightOf="@id/tv_order_number_text" app:layout_constraintLeft_toRightOf="@id/tv_order_number_text"
app:layout_constraintTop_toTopOf="@id/tv_order_number_text" /> app:layout_constraintTop_toTopOf="@id/tv_order_number_text" />
<TextView <TextView
android:id="@+id/tv_data_text" android:id="@+id/tv_data_text"
style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="下單時間:" android:text="下單時間:"
style="@style/Print_text_style"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_order_number_text" /> app:layout_constraintTop_toBottomOf="@id/tv_order_number_text" />
<TextView <TextView
android:id="@+id/tv_date" android:id="@+id/tv_date"
style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/Print_text_style"
app:layout_constraintLeft_toRightOf="@id/tv_data_text" app:layout_constraintLeft_toRightOf="@id/tv_data_text"
app:layout_constraintTop_toBottomOf="@id/tv_order_number_text" /> app:layout_constraintTop_toBottomOf="@id/tv_order_number_text" />
<TextView <TextView
android:id="@+id/line_order_info" android:id="@+id/line_order_info"
style="@style/Print_text_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:maxLines="1" android:maxLines="1"
style="@style/Print_text_style"
android:text="——————————————————————————————————————————————————" android:text="——————————————————————————————————————————————————"
app:layout_constraintTop_toBottomOf="@id/tv_date" /> app:layout_constraintTop_toBottomOf="@id/tv_date" />
...@@ -199,23 +205,23 @@ ...@@ -199,23 +205,23 @@
<TextView <TextView
android:id="@+id/tv_amount" android:id="@+id/tv_amount"
style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_5"
android:text="$" android:text="$"
style="@style/Print_text_style"
app:layout_constraintRight_toLeftOf="@id/tv_total_amount" app:layout_constraintRight_toLeftOf="@id/tv_total_amount"
app:layout_constraintTop_toBottomOf="@id/line_price_info" /> app:layout_constraintTop_toBottomOf="@id/line_price_info" />
<TextView <TextView
android:id="@+id/tv_total_amount" android:id="@+id/tv_total_amount"
style="@style/Print_text_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="@dimen/dp_5" android:layout_marginLeft="@dimen/dp_5"
android:text="0" android:text="0"
style="@style/Print_text_style"
app:layout_constraintBottom_toBottomOf="@id/tv_amount" app:layout_constraintBottom_toBottomOf="@id/tv_amount"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_amount" /> app:layout_constraintTop_toTopOf="@id/tv_amount" />
......
...@@ -633,7 +633,6 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow ...@@ -633,7 +633,6 @@ public class DownloadPresenter extends BasePresenter<DownloadContract.Model, Dow
@Override @Override
public void onNext(@NonNull BaseResult result) { public void onNext(@NonNull BaseResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
if (result.getData() != null) { if (result.getData() != null) {
ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(IActivity); ExpandInfoDaoUtils expandInfoDaoUtils = new ExpandInfoDaoUtils(IActivity);
expandInfoDaoUtils.deleteAll(); expandInfoDaoUtils.deleteAll();
......
...@@ -16,6 +16,8 @@ import retrofit2.http.Query; ...@@ -16,6 +16,8 @@ import retrofit2.http.Query;
*/ */
public interface MainService { public interface MainService {
// @Headers({"Domain-Name: system_url"})/**/
@POST("user/logout" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @POST("user/logout" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<Object> loginOut(@Body RequestBody requestBody); Observable<Object> loginOut(@Body RequestBody requestBody);
......
...@@ -468,7 +468,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -468,7 +468,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
launch({ launch({
//單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯 //單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯
repository.addPrj(dataBean.Order_ID.toString(), restaurantId, ids.toString()) repository.addPrj(dataBean.Order_ID.toString(), restaurantId, ids.toString(), GsaCloudApplication.getMemberId(GsaCloudApplication.getAppContext()).toString())
GetInfoUpdateService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString()) GetInfoUpdateService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString())
GetInfoUpdateService.loginfo.append("\n") GetInfoUpdateService.loginfo.append("\n")
}, { }, {
...@@ -482,7 +482,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -482,7 +482,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
// 初始化用於打印的view // 初始化用於打印的view
// 送單成功後,再調用接口獲取取餐碼 // 送單成功後,再調用接口獲取取餐碼
repository.getOrderInfo(dataBean.ID.toString()).apply { repository.getOrderInfo(dataBean.ID.toString()).apply {
if(data != null && data!!.isNotEmpty()){ if (data != null && data!!.isNotEmpty()) {
data?.get(0)?.let { data?.get(0)?.let {
it.order_type = dataBean.order_type it.order_type = dataBean.order_type
it.orderPayType = dataBean.orderPayType it.orderPayType = dataBean.orderPayType
...@@ -534,13 +534,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -534,13 +534,13 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
* 打開錢箱 * 打開錢箱
*/ */
fun openCashBox() { fun openCashBox() {
launch({ // launch({
//單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯 // //單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯
repository.addPrj("11112364", "153", "48863116,48863117,48863119") // repository.addPrj("11112364", "153", "48863116,48863117,48863119")
}, { // }, {
it.printStackTrace() // it.printStackTrace()
Log.e("eee", "錯誤信息222:" + it.message) // Log.e("eee", "錯誤信息222:" + it.message)
}) // })
CC.obtainBuilder("Component.Print") CC.obtainBuilder("Component.Print")
.addParam(PrintConstans.PRINT_TYPE, 6) .addParam(PrintConstans.PRINT_TYPE, 6)
.addParam(PrintConstans.PRINT_LOADING, false) .addParam(PrintConstans.PRINT_LOADING, false)
......
...@@ -248,7 +248,7 @@ class GetInfoUpdateService : Service() { ...@@ -248,7 +248,7 @@ class GetInfoUpdateService : Service() {
Log.e(TAG, "onFailure" + t!!.message) Log.e(TAG, "onFailure" + t!!.message)
if (!this@GetInfoUpdateService.isDestroy) { if (!this@GetInfoUpdateService.isDestroy) {
// Log.e(TAG, "沒銷毀") // Log.e(TAG, "沒銷毀")
// initSocket()//创建一个新的连接 // initSocket()//创建一个新的连接Expected HTTP 101 response but was '502 Bad Gateway'
} else { } else {
webSocket?.cancel() webSocket?.cancel()
it.dispatcher().cancelAll() it.dispatcher().cancelAll()
......
...@@ -131,6 +131,7 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -131,6 +131,7 @@ class OrderDetailsActivity : BaseActivity() {
if (orderDetails.isDelete == 0) { if (orderDetails.isDelete == 0) {
//如果是第三方物流,不顯示結賬按鈕 //如果是第三方物流,不顯示結賬按鈕
} else { } else {
btnList.add(BtnBuilder().getAssignDeliveryBtn())
btnList.add(BtnBuilder().getClosingBtn()) btnList.add(BtnBuilder().getClosingBtn())
} }
orderStatusText = "派送中" orderStatusText = "派送中"
......
...@@ -43,6 +43,10 @@ ...@@ -43,6 +43,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:paddingTop="@dimen/dp_5"
android:paddingBottom="@dimen/dp_5"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:background="@drawable/shape_cloas_btn" android:background="@drawable/shape_cloas_btn"
android:text="停止接單" android:text="停止接單"
android:textColor="@color/white" android:textColor="@color/white"
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" /> android:value="ConfigModule" />
<activity android:name=".mvp.ui.activity.PrintTestActivity"/> <activity android:name=".mvp.ui.activity.PrintTestActivity"/>
<activity android:name=".mvp.ui.activity.PrintAddCurrencyActivity"/>
</application> </application>
......
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" <?xml version="1.0" encoding="utf-8"?>
package="com.joe.print"> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.joe.print">
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <application
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication"
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> android:allowBackup="true"
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /> android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_android"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.PrintAddCurrencyActivity"></activity>
<activity android:name=".mvp.ui.activity.PrintActivity" />
<activity android:name=".mvp.ui.activity.PrinterAddActivity" />
<activity android:name=".mvp.ui.activity.PrintTestActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".mvp.ui.activity.PrinterListActivity" />
<application <meta-data
android:name="com.gingersoft.gsa.cloud.base.application.GsaCloudApplication" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:allowBackup="true" android:value="ConfigModule" />
android:icon="@mipmap/ic_launcher" </application>
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_android"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.PrintActivity" />
<activity android:name=".mvp.ui.activity.PrinterAddActivity" />
<activity android:name=".mvp.ui.activity.PrintTestActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" /> </manifest>
</intent-filter> \ No newline at end of file
</activity>
<activity android:name="com.joe.print.mvp.ui.activity.PrinterListActivity"/>
<meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" />
</application>
</manifest>
package com.joe.print.di.component;
import dagger.Component;
import com.jess.arms.di.component.AppComponent;
import com.joe.print.di.module.PrintAddCurrencyModule;
import com.jess.arms.di.scope.ActivityScope;
import com.joe.print.mvp.ui.activity.PrintAddCurrencyActivity;
@ActivityScope
@Component(modules = PrintAddCurrencyModule.class, dependencies = AppComponent.class)
public interface PrintAddCurrencyComponent {
void inject(PrintAddCurrencyActivity activity);
}
\ No newline at end of file
package com.joe.print.di.module;
import com.jess.arms.di.scope.ActivityScope;
import dagger.Module;
import dagger.Provides;
import com.joe.print.mvp.contract.PrintAddCurrencyContract;
import com.joe.print.mvp.model.PrintAddCurrencyModel;
@Module
public class PrintAddCurrencyModule {
private PrintAddCurrencyContract.View view;
/**
* 构建PrintAddCurrencyModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
*
* @param view
*/
public PrintAddCurrencyModule(PrintAddCurrencyContract.View view) {
this.view = view;
}
@ActivityScope
@Provides
PrintAddCurrencyContract.View providePrintAddCurrencyView() {
return this.view;
}
@ActivityScope
@Provides
PrintAddCurrencyContract.Model providePrintAddCurrencyModel(PrintAddCurrencyModel model) {
return model;
}
}
\ No newline at end of file
package com.joe.print.mvp.contract; package com.joe.print.mvp.contract;
import com.gingersoft.gsa.cloud.bean.PublicBean;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.jess.arms.mvp.IView; import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel; import com.jess.arms.mvp.IModel;
import java.util.List;
import io.reactivex.Observable;
public interface LocalPrintContract { public interface LocalPrintContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息 //对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView { interface View extends IView {
void loadView(List<PrintCurrencyBean> printCurrencyBeans);
} }
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存 //Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel { interface Model extends IModel {
Observable<PublicBean> getPrinterCurrencyList(String restaurantId);
} }
} }
package com.joe.print.mvp.contract;
import com.gingersoft.gsa.cloud.bean.PublicBean;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import io.reactivex.Observable;
import okhttp3.RequestBody;
public interface PrintAddCurrencyContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void addSuccess(boolean isSuccess);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<PublicBean> getPrinterCurrencyList(String restaurantId);
Observable<PublicBean> addPrinterCurrency(RequestBody requestBody);
}
}
...@@ -2,6 +2,7 @@ package com.joe.print.mvp.model; ...@@ -2,6 +2,7 @@ package com.joe.print.mvp.model;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.bean.PublicBean;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager; import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel; import com.jess.arms.mvp.BaseModel;
...@@ -11,6 +12,9 @@ import com.jess.arms.di.scope.FragmentScope; ...@@ -11,6 +12,9 @@ import com.jess.arms.di.scope.FragmentScope;
import javax.inject.Inject; import javax.inject.Inject;
import com.joe.print.mvp.contract.LocalPrintContract; import com.joe.print.mvp.contract.LocalPrintContract;
import com.joe.print.mvp.model.server.PrintInfoService;
import io.reactivex.Observable;
@FragmentScope @FragmentScope
...@@ -31,4 +35,9 @@ public class LocalPrintModel extends BaseModel implements LocalPrintContract.Mod ...@@ -31,4 +35,9 @@ public class LocalPrintModel extends BaseModel implements LocalPrintContract.Mod
this.mGson = null; this.mGson = null;
this.mApplication = null; this.mApplication = null;
} }
@Override
public Observable<PublicBean> getPrinterCurrencyList(String restaurantId) {
return mRepositoryManager.obtainRetrofitService(PrintInfoService.class).getCurrencyPrenterList(restaurantId);
}
} }
\ No newline at end of file
package com.joe.print.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.bean.PublicBean;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
import com.jess.arms.di.scope.ActivityScope;
import javax.inject.Inject;
import com.joe.print.mvp.contract.PrintAddCurrencyContract;
import com.joe.print.mvp.model.server.PrintInfoService;
import io.reactivex.Observable;
import okhttp3.RequestBody;
@ActivityScope
public class PrintAddCurrencyModel extends BaseModel implements PrintAddCurrencyContract.Model {
@Inject
Gson mGson;
@Inject
Application mApplication;
@Inject
public PrintAddCurrencyModel(IRepositoryManager repositoryManager) {
super(repositoryManager);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<PublicBean> getPrinterCurrencyList(String restaurantId) {
return mRepositoryManager.obtainRetrofitService(PrintInfoService.class).getCurrencyPrenterList(restaurantId);
}
@Override
public Observable<PublicBean> addPrinterCurrency(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(PrintInfoService.class).addCurrencyPrenter(requestBody);
}
}
\ No newline at end of file
...@@ -70,15 +70,15 @@ public class PrjBean { ...@@ -70,15 +70,15 @@ public class PrjBean {
private int type; private int type;
private int printerType; private int printerType;
private Long printerTime; private Long printerTime;
private String number; private int number;
private String productId; private String productId;
private Long createTime; private Long createTime;
private int requests; private int requests;
private int actualPrinterDeviceId; private int actualPrinterDeviceId;
private String takeFoodCode; private String takeFoodCode; //取餐碼
private String billNo; private String billNo;//訂單碼
private int orderType; private int orderType;//訂單類型
/*** /***
* 層級 * 層級
* 1:主食品 * 1:主食品
...@@ -211,11 +211,11 @@ public class PrjBean { ...@@ -211,11 +211,11 @@ public class PrjBean {
this.printerTime = printerTime; this.printerTime = printerTime;
} }
public String getNumber() { public int getNumber() {
return number; return number;
} }
public void setNumber(String number) { public void setNumber(int number) {
this.number = number; this.number = number;
} }
......
package com.joe.print.mvp.model.server; package com.joe.print.mvp.model.server;
import com.gingersoft.gsa.cloud.ui.bean.mode.LoginBean;
import io.reactivex.Observable; import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager; import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import retrofit2.http.GET; import retrofit2.http.GET;
......
...@@ -2,13 +2,13 @@ package com.joe.print.mvp.model.server; ...@@ -2,13 +2,13 @@ package com.joe.print.mvp.model.server;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult; import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.bean.PublicBean;
import io.reactivex.Observable; import io.reactivex.Observable;
import me.jessyan.retrofiturlmanager.RetrofitUrlManager; import me.jessyan.retrofiturlmanager.RetrofitUrlManager;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST; import retrofit2.http.POST;
import retrofit2.http.Query; import retrofit2.http.Query;
...@@ -35,5 +35,9 @@ public interface PrintInfoService { ...@@ -35,5 +35,9 @@ public interface PrintInfoService {
@GET("printerModel/list?" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2) @GET("printerModel/list?" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getPrinterModelList(@Query("restaurantId") int restaurantId); Observable<BaseResult> getPrinterModelList(@Query("restaurantId") int restaurantId);
@GET("printerComplexionConfig/list?" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<PublicBean> getCurrencyPrenterList(@Query("restaurantId") String restaurantId);
@POST("printerComplexionConfig/insert" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<PublicBean> addCurrencyPrenter(@Body RequestBody requestBody);
} }
...@@ -2,15 +2,24 @@ package com.joe.print.mvp.presenter; ...@@ -2,15 +2,24 @@ package com.joe.print.mvp.presenter;
import android.app.Application; import android.app.Application;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.bean.PublicBean;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.jess.arms.di.scope.FragmentScope; import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader; import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager; import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter; import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.joe.print.mvp.contract.LocalPrintContract; import com.joe.print.mvp.contract.LocalPrintContract;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler; import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
@FragmentScope @FragmentScope
...@@ -37,4 +46,27 @@ public class LocalPrintPresenter extends BasePresenter<LocalPrintContract.Model, ...@@ -37,4 +46,27 @@ public class LocalPrintPresenter extends BasePresenter<LocalPrintContract.Model,
this.mImageLoader = null; this.mImageLoader = null;
this.mApplication = null; this.mApplication = null;
} }
public void getPrinterCurrencyList(int restaurant) {
mModel.getPrinterCurrencyList(restaurant + "")
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<PublicBean>(mErrorHandler) {
@Override
public void onNext(PublicBean baseResult) {
if (baseResult != null) {
List<PrintCurrencyBean> printCurrencyBeans = JsonUtils.parseArray(baseResult.getData(), PrintCurrencyBean.class);
mRootView.loadView(printCurrencyBeans);
} else {
mRootView.loadView(null);
}
}
});
}
} }
package com.joe.print.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.base.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.bean.PublicBean;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import javax.inject.Inject;
import com.jess.arms.utils.RxLifecycleUtils;
import com.joe.print.mvp.contract.PrintAddCurrencyContract;
import java.util.List;
@ActivityScope
public class PrintAddCurrencyPresenter extends BasePresenter<PrintAddCurrencyContract.Model, PrintAddCurrencyContract.View> {
@Inject
RxErrorHandler mErrorHandler;
@Inject
Application mApplication;
@Inject
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
@Inject
public PrintAddCurrencyPresenter(PrintAddCurrencyContract.Model model, PrintAddCurrencyContract.View rootView) {
super(model, rootView);
}
@Override
public void onDestroy() {
super.onDestroy();
this.mErrorHandler = null;
this.mAppManager = null;
this.mImageLoader = null;
this.mApplication = null;
}
public void addCurrencyPresenter(PrintCurrencyBean printCurrencyBean) {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), JsonUtils.toJson(printCurrencyBean));
mModel.addPrinterCurrency(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(""))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<PublicBean>(mErrorHandler) {
@Override
public void onNext(PublicBean s) {
if (s != null) {
mRootView.addSuccess(s.isSuccess());
} else {
mRootView.addSuccess(false);
}
}
});
}
private RequestBody getRequestBody(PrintCurrencyBean printCurrencyBean) {
FormBody.Builder builder = new FormBody.Builder()
.add("restaurantId", printCurrencyBean.getRestaurantId() + "")
.add("type", printCurrencyBean.getType() + "")
.add("foodComplexion", printCurrencyBean.getFoodComplexion() + "")
.add("modifierComplexion", printCurrencyBean.getModifierComplexion() + "")
.add("uid", printCurrencyBean.getUid() + "")
.add("foodIsBold", printCurrencyBean.getFoodIsBold() + "")
.add("foodFont", printCurrencyBean.getFoodFont() + "")
.add("foodIsItalic", printCurrencyBean.getFoodIsItalic() + "")
.add("modifierIsBold", printCurrencyBean.getModifierIsBold() + "")
.add("modifierFont", printCurrencyBean.getModifierFont() + "")
.add("modifierIsItalic", printCurrencyBean.getModifierIsItalic() + "")
.add("numberIsFlip", printCurrencyBean.getNumberIsFlip() + "");
return builder.build();
}
}
...@@ -142,7 +142,14 @@ public class PrinterAddPresenter extends BasePresenter<PrinterAddContract.Model, ...@@ -142,7 +142,14 @@ public class PrinterAddPresenter extends BasePresenter<PrinterAddContract.Model,
.add("port", printerDeviceBean.getPort() + "") .add("port", printerDeviceBean.getPort() + "")
.add("printerModelId", printerDeviceBean.getPrinterModelId() + "") .add("printerModelId", printerDeviceBean.getPrinterModelId() + "")
.add("type", printerDeviceBean.getType() + "") .add("type", printerDeviceBean.getType() + "")
.add("id", printerDeviceBean.getId() + ""); .add("id", printerDeviceBean.getId() + "")
.add("foodIsBold", printerDeviceBean.getFoodIsBold() + "")
.add("foodFont", printerDeviceBean.getFoodFont() + "")
.add("foodIsItalic", printerDeviceBean.getFoodIsItalic() + "")
.add("modifierIsBold", printerDeviceBean.getModifierIsBold() + "")
.add("modifierFont", printerDeviceBean.getModifierFont() + "")
.add("modifierIsItalic", printerDeviceBean.getModifierIsItalic() + "")
.add("numberIsFlip", printerDeviceBean.getNumberIsFlip() + "");
if (printerDeviceBean.getFlyPrinterDeviceId() != null) { if (printerDeviceBean.getFlyPrinterDeviceId() != null) {
builder.add("flyPrinterDeviceId", printerDeviceBean.getFlyPrinterDeviceId() + ""); builder.add("flyPrinterDeviceId", printerDeviceBean.getFlyPrinterDeviceId() + "");
} }
......
...@@ -94,8 +94,6 @@ public class EpsonPrint implements ReceiveListener { ...@@ -94,8 +94,6 @@ public class EpsonPrint implements ReceiveListener {
mPrinter = null; mPrinter = null;
} }
private int lineCount = 42;
/** /**
* 創建打印數據 * 創建打印數據
* *
...@@ -241,7 +239,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -241,7 +239,7 @@ public class EpsonPrint implements ReceiveListener {
private String ipAddress; private String ipAddress;
private List<Bitmap> bitmaps = new ArrayList<>(); private List<Bitmap> bitmaps = new ArrayList<>();
public void putPrintString(String ip, List<PrintInfoBean> printInfoBeans) { public void putPrintString(String ip, int paperWidth, List<PrintInfoBean> printInfoBeans) {
if (mPrinter == null) { if (mPrinter == null) {
return; return;
} }
...@@ -260,7 +258,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -260,7 +258,7 @@ public class EpsonPrint implements ReceiveListener {
} }
//如果打印多列內容,並且字體大小配置多個,則每一列取自己對應的字體大小 //如果打印多列內容,並且字體大小配置多個,則每一列取自己對應的字體大小
for (int i = 0; i < printInfoBean.getContent().length; i++) { for (int i = 0; i < printInfoBean.getContent().length; i++) {
print(printInfoBean, i); print(printInfoBean, i, paperWidth);
} }
mPrinter.addFeedLine(1); mPrinter.addFeedLine(1);
} }
...@@ -274,42 +272,120 @@ public class EpsonPrint implements ReceiveListener { ...@@ -274,42 +272,120 @@ public class EpsonPrint implements ReceiveListener {
} }
private int location = 0; private int location = 0;
private void print(PrintInfoBean printInfoBean, int i) throws Epos2Exception {
private void print(PrintInfoBean printInfoBean, int i, int paperWidth) throws Epos2Exception {
if (i == 0) { if (i == 0) {
location = 0; location = 0;
} }
int color;
int textSize;
int isItalic;
if (printInfoBean.getColor().length == 1) {
color = printInfoBean.getColor()[0];
} else {
color = printInfoBean.getColor()[i];
}
if (color > 4) {
color = 4;
}
if (printInfoBean.getIsItalic().length == 1) {
isItalic = printInfoBean.getIsItalic()[0] ? 1 : 0;
} else {
isItalic = printInfoBean.getIsItalic()[i] ? 1 : 0;
}
if (printInfoBean.getIsBold().length == 1) { if (printInfoBean.getIsBold().length == 1) {
mPrinter.addTextStyle(0, 0, printInfoBean.getIsBold()[0] ? 1 : 0, Printer.COLOR_1); mPrinter.addTextStyle(0, isItalic, printInfoBean.getIsBold()[0] ? 1 : 0, color);
} else { } else {
if (printInfoBean.getIsBold()[i]) { if (printInfoBean.getIsBold()[i]) {
mPrinter.addTextStyle(0, 0, 0, Printer.COLOR_1); mPrinter.addTextStyle(0, isItalic, 0, color);
} else { } else {
mPrinter.addTextStyle(0, 0, 1, Printer.COLOR_1); mPrinter.addTextStyle(0, isItalic, 1, color);
} }
} }
StringBuilder space = new StringBuilder(); StringBuilder space = new StringBuilder();
if (printInfoBean.getSize().length == 1) { if (printInfoBean.getSize().length == 1) {
for (int j = 0; j < location/printInfoBean.getSize()[0]; j++) { for (int j = 0; j < location / printInfoBean.getSize()[0]; j++) {
space.append(" "); space.append(" ");
} }
mPrinter.addTextSize((int) printInfoBean.getSize()[0], (int) printInfoBean.getSize()[0]); textSize = (int) printInfoBean.getSize()[0];
location += printInfoBean.getContent()[i].length() * printInfoBean.getSize()[0]; mPrinter.addTextSize(textSize, textSize);
location += getChineseValueLength(printInfoBean.getContent()[i]) * printInfoBean.getSize()[0];
} else { } else {
for (int j = 0; j < location/printInfoBean.getSize()[i]; j++) { for (int j = 0; j < location / printInfoBean.getSize()[i]; j++) {
space.append(" "); space.append(" ");
} }
mPrinter.addTextSize((int) printInfoBean.getSize()[i], (int) printInfoBean.getSize()[i]); textSize = (int) printInfoBean.getSize()[i];
location += printInfoBean.getContent()[i].length() * printInfoBean.getSize()[i]; mPrinter.addTextSize(textSize, textSize);
location += getChineseValueLength(printInfoBean.getContent()[i]) * printInfoBean.getSize()[i];
} }
if (printInfoBean.getLanguage().length == 1) { if (printInfoBean.getLanguage().length == 1) {
setLanguage(printInfoBean.getLanguage()[0]); setLanguage(printInfoBean.getLanguage()[0]);
} else { } else {
setLanguage(printInfoBean.getLanguage()[i]); setLanguage(printInfoBean.getLanguage()[i]);
} }
mPrinter.addText(space + printInfoBean.getContent()[i]); mPrinter.addText(getFormatText(space + printInfoBean.getContent()[i], paperWidth / textSize));
// mPrinter.addLineSpace(100);//行間距 // mPrinter.addLineSpace(100);//行間距
} }
private static String abc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
/**
* 如果超過紙張寬度的英文,換行時,要截取得當
* 23
*
* @return
*/
private static String getFormatText(String content, int paperWidth) {
if (content.length() > paperWidth) {
int lastIndex = 0;//上次截取時最後的下標
StringBuilder stringBuilder = new StringBuilder();
while (true) {
if (lastIndex + paperWidth >= content.length()) {
String footStr = content.substring(lastIndex);
stringBuilder.append(footStr);
return stringBuilder.toString();
} else {
String headerStr = content.substring(lastIndex, lastIndex + paperWidth);
String nextContext = content.substring(lastIndex + paperWidth, lastIndex + paperWidth + 1);
if (abc.contains(headerStr.charAt(headerStr.length() - 1) + "") && abc.contains(nextContext)) {
//如果最後一位是英文單詞,往前找找到空格或者不是英文的,然後換行
for (int j = headerStr.length() - 1; j >= 0; j--) {
String tchar = headerStr.charAt(j) + "";
if (j == 0) {
//循環完了都沒找到,就不管了
stringBuilder.append(headerStr);
stringBuilder.append("\n");
lastIndex += paperWidth;
break;
}
if (!abc.contains(tchar)) {
//找到不是英文的那個
String newHeaderStr = headerStr.substring(0, j + 1);
stringBuilder.append(newHeaderStr);
stringBuilder.append("\n");
lastIndex += j + 1;
break;
}
}
} else {
lastIndex += paperWidth;
stringBuilder.append(headerStr);
stringBuilder.append("\n");
}
}
}
} else {
return content;
}
}
public static void main(String[] args) {
String str = "asd asdfa asdf sdjn sdf0";
System.out.println(getFormatText(str, 20));
}
private void setLanguage(String language) throws Epos2Exception { private void setLanguage(String language) throws Epos2Exception {
if ("en".equals(language)) { if ("en".equals(language)) {
//切換對應語言 //切換對應語言
...@@ -369,6 +445,9 @@ public class EpsonPrint implements ReceiveListener { ...@@ -369,6 +445,9 @@ public class EpsonPrint implements ReceiveListener {
return 0; return 0;
} }
connectByIp(ip, mPrinter.getStatus()); connectByIp(ip, mPrinter.getStatus());
if (mPrinter == null) {
return 0;
}
PrinterStatusInfo statusInfo = mPrinter.getStatus(); PrinterStatusInfo statusInfo = mPrinter.getStatus();
// if (statusInfo.getConnection() != 1) { // if (statusInfo.getConnection() != 1) {
// if (resetCount > 0) { // if (resetCount > 0) {
...@@ -448,7 +527,6 @@ public class EpsonPrint implements ReceiveListener { ...@@ -448,7 +527,6 @@ public class EpsonPrint implements ReceiveListener {
if (ipAddress != null && !ipAddress.equals(ip)) { if (ipAddress != null && !ipAddress.equals(ip)) {
Log.e(TAG, "不是上次的ip,斷開重連"); Log.e(TAG, "不是上次的ip,斷開重連");
disconnectPrinter(); disconnectPrinter();
finalizeObject();
if (connectPrinter(ip)) { if (connectPrinter(ip)) {
ipAddress = ip; ipAddress = ip;
} }
...@@ -490,6 +568,7 @@ public class EpsonPrint implements ReceiveListener { ...@@ -490,6 +568,7 @@ public class EpsonPrint implements ReceiveListener {
Log.e(TAG, "連接打印機報錯" + e.getMessage() + e.getClass().getName()); Log.e(TAG, "連接打印機報錯" + e.getMessage() + e.getClass().getName());
e.printStackTrace(); e.printStackTrace();
disconnectPrinter(); disconnectPrinter();
finalizeObject();
return false; return false;
} }
return true; return true;
......
...@@ -219,15 +219,23 @@ public class PrintOtherOrder extends PrinterRoot { ...@@ -219,15 +219,23 @@ public class PrintOtherOrder extends PrinterRoot {
setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外送" : "自取"); setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外送" : "自取");
// 訂單號 // 訂單號
setText(view, R.id.tv_order_number, "單號:" + data.getORDER_NO()); setText(view, R.id.tv_order_number, "單號:" + data.getORDER_NO());
if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) { if (data.getOrder_type() == 7) {
setText(view, R.id.tv_order_take_food_code, "取餐碼:#" + data.getTakeFoodCode()); //自取 顯示 取餐碼+訂單碼
if (!TextUtil.isEmptyOrNullOrUndefined(data.getTakeFoodCode())) {
setText(view, R.id.tv_order_take_food_code, "取餐碼:" + data.getTakeFoodCode());
}
} else { } else {
//外送 顯示訂單碼
setText(view, R.id.tv_order_take_food_code, "訂單碼:" + data.getTakeFoodCode());
}
if (data.getTakeFoodCode() == null || data.getTakeFoodCode().equals("0")) {
view.findViewById(R.id.tv_order_take_food_code).setVisibility(View.GONE); view.findViewById(R.id.tv_order_take_food_code).setVisibility(View.GONE);
} }
if (data.getBillNo() == null || data.getBillNo().length() <= 0) { if (data.getBillNo() == null || data.getBillNo().length() <= 0) {
tvBillNumber.setVisibility(View.GONE); tvBillNumber.setVisibility(View.GONE);
} else { } else {
tvBillNumber.setText("訂單:" + data.getBillNo()); tvBillNumber.setText("訂單:" + data.getBillNo());
} }
//訂單創建時間 //訂單創建時間
setText(view, R.id.tv_order_create, context.getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(data.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT)); setText(view, R.id.tv_order_create, context.getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(data.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT));
......
...@@ -62,7 +62,6 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -62,7 +62,6 @@ public class PrintOtherOrderClosing extends PrinterRoot {
private Bitmap initPrintView(Context context, OrderDetails.DataBean data) { private Bitmap initPrintView(Context context, OrderDetails.DataBean data) {
View view = LayoutInflater.from(context).inflate(R.layout.print_confirm_order_view, null, false); View view = LayoutInflater.from(context).inflate(R.layout.print_confirm_order_view, null, false);
TextView tvMemberNum = view.findViewById(R.id.tv_member_number);//會員號碼 TextView tvMemberNum = view.findViewById(R.id.tv_member_number);//會員號碼
TextView tvMemberName = view.findViewById(R.id.tv_member_name);//會員名稱 TextView tvMemberName = view.findViewById(R.id.tv_member_name);//會員名稱
TextView tvMemberPhone = view.findViewById(R.id.tv_member_phone);//會員電話 TextView tvMemberPhone = view.findViewById(R.id.tv_member_phone);//會員電話
...@@ -76,19 +75,26 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -76,19 +75,26 @@ public class PrintOtherOrderClosing extends PrinterRoot {
setText(view, R.id.tv_brand_name, GsaCloudApplication.getBrandName(context)); setText(view, R.id.tv_brand_name, GsaCloudApplication.getBrandName(context));
//餐廳名 //餐廳名
setText(view, R.id.tv_restaurant_name, GsaCloudApplication.getRestaurantName(context)); setText(view, R.id.tv_restaurant_name, GsaCloudApplication.getRestaurantName(context));
// 訂單類型
setText(view, R.id.tv_order_type, data.getOrder_type() == 2 ? "外送" : "自取");
// 訂單號 // 訂單號
setText(view, R.id.tv_order_number, "單號:" + data.getORDER_NO()); setText(view, R.id.tv_order_number, "單號:" + data.getORDER_NO());
if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) { tvBillNumber.setVisibility(View.GONE);
setText(view, R.id.tv_order_take_food_code, "取餐碼:#" + data.getTakeFoodCode()); if (data.getOrder_type() == 2) {
} else { //外送
view.findViewById(R.id.tv_order_take_food_code).setVisibility(View.GONE); // 訂單類型
} setText(view, R.id.tv_order_type, "外送");
if (data.getBillNo() == null || data.getBillNo().length() <= 0) { if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) {
tvBillNumber.setVisibility(View.GONE); setText(view, R.id.tv_order_take_food_code, "訂單碼:" + data.getTakeFoodCode());
} else if (data.getBillNo() != null && data.getBillNo().length() > 0) {
setText(view, R.id.tv_order_take_food_code, "訂單碼:" + data.getTakeFoodCode());
}
} else { } else {
tvBillNumber.setText("訂單號:" + data.getBillNo()); setText(view, R.id.tv_order_type, "自取");
if (data.getBillNo() != null && data.getBillNo().length() > 0) {
setText(view, R.id.tv_order_take_food_code, "訂單碼:" + data.getBillNo());
} else if (data.getTakeFoodCode() != null && !data.getTakeFoodCode().equals("0")) {
setText(view, R.id.tv_order_take_food_code, "訂單碼:" + data.getTakeFoodCode());
}
} }
//訂單創建時間 //訂單創建時間
setText(view, R.id.tv_order_create, context.getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(data.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT)); setText(view, R.id.tv_order_create, context.getString(R.string.create_order_time) + TimeUtils.parseTimeRepeat(data.getCREATE_TIME(), TimeUtils.DEFAULT_DATE_FORMAT));
...@@ -120,8 +126,8 @@ public class PrintOtherOrderClosing extends PrinterRoot { ...@@ -120,8 +126,8 @@ public class PrintOtherOrderClosing extends PrinterRoot {
//支付金額 //支付金額
setText(view, R.id.tv_pay_amount_text, data.getPayName() + ":" + amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount())); setText(view, R.id.tv_pay_amount_text, data.getPayName() + ":" + amountUnit + MoneyUtil.sub(Double.parseDouble(data.getTOTAL_AMOUNT()), data.getDiscount_amount()));
} else { } else {
setIsShow(view, R.id.tv_pay_amount_text,false); setIsShow(view, R.id.tv_pay_amount_text, false);
setIsShow(view, R.id.tv_pay_amount_line,false); setIsShow(view, R.id.tv_pay_amount_line, false);
} }
} else if (data.getOrderPayType() == 0) { } else if (data.getOrderPayType() == 0) {
setText(view, R.id.tv_pay_type, "店內支付"); setText(view, R.id.tv_pay_type, "店內支付");
......
...@@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.base.adapter.print.BillAdapter; import com.gingersoft.gsa.cloud.base.adapter.print.BillAdapter;
import com.gingersoft.gsa.cloud.base.adapter.print.FoodAdapter; import com.gingersoft.gsa.cloud.base.adapter.print.FoodAdapter;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.common.bean.BillingBean; import com.gingersoft.gsa.cloud.base.common.bean.BillingBean;
import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail; import com.gingersoft.gsa.cloud.base.common.bean.OrderDetail;
import com.gingersoft.gsa.cloud.base.common.bean.TableBean; import com.gingersoft.gsa.cloud.base.common.bean.TableBean;
...@@ -70,9 +71,10 @@ public class PrintServe extends PrinterRoot { ...@@ -70,9 +71,10 @@ public class PrintServe extends PrinterRoot {
TextView checkOutTime = view.findViewById(R.id.tv_checkout_time); TextView checkOutTime = view.findViewById(R.id.tv_checkout_time);
TextView line_food_info = view.findViewById(R.id.line_food_info); TextView line_food_info = view.findViewById(R.id.line_food_info);
TableBean.DataBean tableBean = OpenTableManage.getDefault().getTableBean(); TableBean.DataBean tableBean = OpenTableManage.getDefault().getTableBean();
brandName.setText(GsaCloudApplication.getBrandName(context));
tableNum.setText(tableBean.getTableName()); restaurantName.setText(GsaCloudApplication.getRestaurantName(context));
people.setText(OpenTableManage.getDefault().getPeopleNumber() + ""); tableNum.setText("餐檯:" + tableBean.getTableName());
people.setText("人數:" + OpenTableManage.getDefault().getPeopleNumber());
orderData.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)); orderData.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT));
...@@ -82,13 +84,15 @@ public class PrintServe extends PrinterRoot { ...@@ -82,13 +84,15 @@ public class PrintServe extends PrinterRoot {
rvFood.setAdapter(foodAdapter); rvFood.setAdapter(foodAdapter);
List<BillingBean> billingBeans = new ArrayList<>(); List<BillingBean> billingBeans = new ArrayList<>();
if (billingBeans.size() <= 0) { // if (billingBeans.size() <= 0) {
line_food_info.setVisibility(View.GONE); line_food_info.setVisibility(View.GONE);
} else { rvBillAmount.setVisibility(View.GONE);
BillAdapter billAdapter = new BillAdapter(billingBeans); view.findViewById(R.id.line_price_info).setVisibility(View.GONE);
rvBillAmount.setLayoutManager(new LinearLayoutManager(context)); // } else {
rvBillAmount.setAdapter(billAdapter); // BillAdapter billAdapter = new BillAdapter(billingBeans);
} // rvBillAmount.setLayoutManager(new LinearLayoutManager(context));
// rvBillAmount.setAdapter(billAdapter);
// }
if (OpenTableManage.getDefault().getTableBean() != null) { if (OpenTableManage.getDefault().getTableBean() != null) {
tableNum.setText(OpenTableManage.getDefault().getTableBean().getTableName()); tableNum.setText(OpenTableManage.getDefault().getTableBean().getTableName());
people.setText(OpenTableManage.getDefault().getPeopleNumber() + ""); people.setText(OpenTableManage.getDefault().getPeopleNumber() + "");
...@@ -103,6 +107,8 @@ public class PrintServe extends PrinterRoot { ...@@ -103,6 +107,8 @@ public class PrintServe extends PrinterRoot {
// totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(OrderDetail.getPrice(), OrderDetail.getNumber())); // totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(OrderDetail.getPrice(), OrderDetail.getNumber()));
// } // }
//總金額 //總金額
view.findViewById(R.id.tv_total_amount_text).setVisibility(View.GONE);
mTvTotalAmount.setVisibility(View.GONE);
mTvTotalAmount.setText(MyOrderManage.getInstance().getTotalAmount() + ""); mTvTotalAmount.setText(MyOrderManage.getInstance().getTotalAmount() + "");
//加载条形码 //加载条形码
// ImageView ivBarCode = view.findViewById(R.id.iv_bar_code); // ImageView ivBarCode = view.findViewById(R.id.iv_bar_code);
......
...@@ -52,7 +52,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -52,7 +52,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
public final static int PRINT_BILL = 2;//結賬單 public final static int PRINT_BILL = 2;//結賬單
public final static int PRINT_KITCHEN = 3;//送單,廚房單 public final static int PRINT_KITCHEN = 3;//送單,廚房單
public final static int PRINT_CLEAN_MACHINE = 4;//清機報表 public final static int PRINT_CLEAN_MACHINE = 4;//清機報表
public final static int PRINT_OTHER_ORDER = 5;//接單內容打印 public final static int PRINT_OTHER_ORDER = 5;//接單內容打印 外送印單
public final static int PRINT_INSTRUCTION = 6;//開錢箱 public final static int PRINT_INSTRUCTION = 6;//開錢箱
public final static int PRINT_OTHER_CLOSING = 7;//外賣結賬單 public final static int PRINT_OTHER_CLOSING = 7;//外賣結賬單
...@@ -436,6 +436,12 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -436,6 +436,12 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
return printerDeviceBean; return printerDeviceBean;
} }
} }
String printDeviceName = (String) SPUtils.get(mContext, "defaultPrint", "");
for (PrinterDeviceBean printerDeviceBean : printerDeviceBeans) {
if (printDeviceName != null && printDeviceName.equals(printerDeviceBean.getName())) {
return printerDeviceBean;
}
}
} }
return null; return null;
} }
...@@ -460,6 +466,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis ...@@ -460,6 +466,7 @@ public abstract class PrinterRoot implements PrintSocketHolder.OnStateChangedLis
printListAdapter.setOnItemClickListener((adapter, view, position) -> { printListAdapter.setOnItemClickListener((adapter, view, position) -> {
//用戶選擇的ip打印機打印 //用戶選擇的ip打印機打印
ipDevicePrint(printerDeviceBeans.get(position), bitmaps); ipDevicePrint(printerDeviceBeans.get(position), bitmaps);
SPUtils.put(mContext, "defaultPrint", printerDeviceBeans.get(position).getName());
dialog.dismiss(); dialog.dismiss();
}); });
} }
......
...@@ -11,22 +11,26 @@ import androidx.annotation.Nullable; ...@@ -11,22 +11,26 @@ import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.JsonUtils; import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils; import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtil;
import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils; import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.constans.HttpsConstans; import com.gingersoft.gsa.cloud.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean; import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils; import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils;
import com.gingersoft.gsa.cloud.print.PrintExecutor; import com.gingersoft.gsa.cloud.print.PrintExecutor;
import com.gingersoft.gsa.cloud.print.PrintSocketHolder; import com.gingersoft.gsa.cloud.print.PrintSocketHolder;
import com.joe.print.mvp.model.bean.PrintInfoBean;
import com.joe.print.mvp.model.bean.PrjBean; import com.joe.print.mvp.model.bean.PrjBean;
import com.joe.print.mvp.print.EpsonPrint;
import com.joe.print.mvp.print.PrintPrjKitchen; import com.joe.print.mvp.print.PrintPrjKitchen;
import com.joe.print.mvp.print.PrinterRoot; import com.joe.print.mvp.print.PrinterRoot;
import com.joe.print.mvp.print.utils.MyPrintUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -137,7 +141,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -137,7 +141,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
//請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢 //請求到數據,停止輪詢,開始打印,在打印完之後再重新開始輪詢
startPrint(s); startPrint(s);
//開啟另一個定時,三十秒之後自動請求,避免上面的打印成功或失敗時沒有回調。 //開啟另一個定時,三十秒之後自動請求,避免上面的打印成功或失敗時沒有回調。
if(wakeDisposable != null){ if (wakeDisposable != null) {
wakeDisposable.dispose(); wakeDisposable.dispose();
} }
Observable.timer(10, TimeUnit.SECONDS) Observable.timer(10, TimeUnit.SECONDS)
...@@ -195,6 +199,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -195,6 +199,7 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
if (prjBean == null || prjBean.getData() == null) { if (prjBean == null || prjBean.getData() == null) {
return; return;
} }
Map<String, List<PrjBean.DataBean.Bean>> listMap = new HashMap<>();
try { try {
JSONObject jsonObject = new JSONObject(prjBean.getData()); JSONObject jsonObject = new JSONObject(prjBean.getData());
//通过迭代器获取这段json当中所有的key值 //通过迭代器获取这段json当中所有的key值
...@@ -205,37 +210,59 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -205,37 +210,59 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
//最后就可以通过刚刚得到的key值去解析后面的json了 //最后就可以通过刚刚得到的key值去解析后面的json了
JSONArray dataJson = (JSONArray) jsonObject.get(key); JSONArray dataJson = (JSONArray) jsonObject.get(key);
List<PrjBean.DataBean.Bean> datas = JsonUtils.parseArray(dataJson.toString(), PrjBean.DataBean.Bean.class); List<PrjBean.DataBean.Bean> datas = JsonUtils.parseArray(dataJson.toString(), PrjBean.DataBean.Bean.class);
// if (key.equals("-1")) { listMap.put(key, datas);//打印位置和需要打印的數據
// PrintPrjKitchen.getPrjMap().put("", datas);
// } else {
Log.e("eee", key + "打印數據條數:" + datas.size());
PrintPrjKitchen.getPrjMap().put(key, datas); PrintPrjKitchen.getPrjMap().put(key, datas);
// }
printDatas.addAll(datas); printDatas.addAll(datas);
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
// updatePrjState(3);
if (printerInIt == null) { if (printerInIt == null) {
printerInIt = PrinterRoot.getPrinterByType(PRINT_KITCHEN); printerInIt = PrinterRoot.getPrinterByType(PRINT_KITCHEN);
} }
// if(printerInIt != null && printerInIt.getPrintBitmap(this).size() <=0){
// return;
// }
getPrintList(); getPrintList();
for (Map.Entry<String, List<PrjBean.DataBean.Bean>> prjMap : listMap.entrySet()) {
for (PrinterDeviceBean deviceBean : printerDeviceBeans) {
if (prjMap.getKey().equalsIgnoreCase(deviceBean.getName())) {
if ((deviceBean.getPrinterName() != null && deviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
&& (deviceBean.getModel() != null && deviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()))) {
//針式打印
//Epson打印機打印,調用對應的方法
EpsonPrint mPrinter = EpsonPrint.getInstance();
// PrinterStatusInfo status = mPrinter.getStatus();
// if (status != null && status.getPaper() == 2) {
// ToastUtils.show(this, "打印機缺紙");
// }
mPrinter.initializeObject(GsaCloudApplication.getAppContext(), null);
int paperWidth = 42;
if (deviceBean.getPaperSpecification() != null) {
paperWidth = (int) (Double.parseDouble(deviceBean.getPaperSpecification()) / 6);
}
PrintCurrencyBean printCurrencyBean = MyPrintUtils.getInstance().getPrintCurrencyBeanByType(this, 2);
List<List<PrintInfoBean>> prjBeans = PrintInfoBean.transPrjBean(prjMap.getValue(), paperWidth, prjMap.getKey(), deviceBean, printCurrencyBean);
for (List<PrintInfoBean> prjPrintBean : prjBeans) {
mPrinter.putPrintString(deviceBean.getIp(), paperWidth, prjPrintBean);
}
}
}
}
}
if (printerInIt != null) { if (printerInIt != null) {
Log.e("aaa", "打印機數量:" +printerDeviceBeans.size());
printerInIt.setmContext(this); printerInIt.setmContext(this);
for (Map.Entry<String, List<Bitmap>> entry : printerInIt.getPrintBitmap(this).entrySet()) { for (Map.Entry<String, List<Bitmap>> entry : printerInIt.getPrintBitmap(this).entrySet()) {
//遍歷所有的需要打印的內容 //遍歷所有的需要打印的內容
for (int i = 0; i < printerDeviceBeans.size(); i++) { for (PrinterDeviceBean deviceBean : printerDeviceBeans) {
//遍歷打印機列表,找到對應的打印機,沒找到的就不打印 //遍歷打印機列表,找到對應的打印機,沒找到的就不打印
if (entry.getKey().equalsIgnoreCase(printerDeviceBeans.get(i).getName())) { if (entry.getKey().equalsIgnoreCase(deviceBean.getName())) {
Log.e("eee", entry.getKey() + "開始打印IP:" + printerDeviceBeans.get(i).getIp()); if ((deviceBean.getPrinterName() != null && deviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
printerInIt.ipDevicePrint(printerDeviceBeans.get(i), entry.getValue(), this, this); && (deviceBean.getModel() != null && deviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()))) {
break; //針式打印機在上面處理
} else {
Log.e("eee", entry.getKey() + "開始打印IP:" + deviceBean.getIp());
printerInIt.ipDevicePrint(deviceBean, entry.getValue(), this, this);
break;
}
} }
} }
} }
......
package com.joe.print.mvp.print.utils;
import android.content.Context;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.database.utils.PrintCurrencyDaoUtils;
import com.gingersoft.gsa.cloud.database.utils.PrinterDeviceDaoUtils;
import com.joe.print.R;
import java.util.List;
public class MyPrintUtils {
private final int HEADER_TEXTSIZE = 26;
private static MyPrintUtils myPrintUtils;
public static MyPrintUtils getInstance() {
if (myPrintUtils == null) {
myPrintUtils = new MyPrintUtils();
}
return myPrintUtils;
}
/**
* 通過類型獲取打印通用配置
*
* @param context
* @param type 1:堂食,2:外送
* @return
*/
public PrintCurrencyBean getPrintCurrencyBeanByType(Context context, int type) {
PrintCurrencyDaoUtils printCurrencyDaoUtils = new PrintCurrencyDaoUtils(context);
List<PrintCurrencyBean> printCurrencyBeans = printCurrencyDaoUtils.queryAllPrintCurrencyBean();
for (PrintCurrencyBean printCurrencyBean : printCurrencyBeans) {
if (printCurrencyBean.getType() == type) {
return printCurrencyBean;
}
}
return null;
}
/**
* 通過打印位置獲取打印機
*
* @param context
* @param printerDeviceName 打印機名稱:打印機位置
* @return
*/
public PrinterDeviceBean getPrinterDeviceByLocation(Context context, String printerDeviceName) {
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(context);
List<PrinterDeviceBean> printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
for (PrinterDeviceBean printerDevice : printerDeviceBeans) {
if (printerDevice.getName() != null && printerDevice.getName().equals(printerDeviceName)) {
return printerDevice;
}
}
}
printerDeviceDaoUtils.closeConnection();
return null;
}
/**
* 獲取默認打印機
*
* @param context
* @return
*/
public PrinterDeviceBean getDefaultPrinterDevice(Context context) {
PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(context);
List<PrinterDeviceBean> printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
if (printerDeviceBeans != null && printerDeviceBeans.size() > 0) {
for (PrinterDeviceBean printerDevice : printerDeviceBeans) {
if (printerDevice.getPrinterDeviceDefaultId() != null) {
return printerDevice;
}
}
}
printerDeviceDaoUtils.closeConnection();
return null;
}
public TextView getBrandName(Context context) {
return getNormalTextView(context, GsaCloudApplication.getBrandName(context), HEADER_TEXTSIZE);
}
public TextView getRestaurantName(Context context) {
return getNormalTextView(context, GsaCloudApplication.getRestaurantName(context), HEADER_TEXTSIZE);
}
public TextView getDashedLine(Context context) {
TextView textView = getNormalTextView(context, context.getString(R.string.print_split_line), HEADER_TEXTSIZE);
textView.setSingleLine(true);
return textView;
}
public TextView getNormalTextView(Context context, String text, int textSize) {
TextView textView = new TextView(context);
textView.setText(text);
textView.setTextSize(textSize);
return textView;
}
}
...@@ -35,11 +35,11 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH ...@@ -35,11 +35,11 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
// printInfoBeans.add(new PrintInfoBean(new String[]{"測試一行多少個字測試一行多少個字測試一"}, new double[]{1}, new String[]{"tw"})); // printInfoBeans.add(new PrintInfoBean(new String[]{"測試一行多少個字測試一行多少個字測試一"}, new double[]{1}, new String[]{"tw"}));
// printInfoBeans.add(new PrintInfoBean(new String[]{"asdfskjflsjflsjlfjslfjsldjflsjfsd"}, new double[]{1}, new String[]{"tw"})); // printInfoBeans.add(new PrintInfoBean(new String[]{"asdfskjflsjflsjlfjslfjsldjflsjfsd"}, new double[]{1}, new String[]{"tw"}));
// printInfoBeans.add(new PrintInfoBean(new String[]{"純屬餐廳"}, new double[]{1}, new String[]{"tw"})); // printInfoBeans.add(new PrintInfoBean(new String[]{"純屬餐廳"}, new double[]{1}, new String[]{"tw"}));
//
printInfoBeans.add(new PrintInfoBean(new String[]{"外賣"}, new Boolean[]{true}, new double[]{2}, 0)); printInfoBeans.add(new PrintInfoBean(new String[]{"外賣"}, new Boolean[]{true}, new double[]{2}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{"訂單碼: ", "0046"}, new Boolean[]{false, true}, new double[]{1, 2}, 0)); printInfoBeans.add(new PrintInfoBean(new String[]{"訂單碼:", "0046"}, new Boolean[]{false, true}, new double[]{1, 2}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{"落單時間: ", "07-13 19:05"}, new double[]{1}, 0)); printInfoBeans.add(new PrintInfoBean(new String[]{"落單時間:", "07-13 19:05"}, new double[]{1}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{"D1廚房 ", "BARRY1"}, new double[]{1}, 0)); printInfoBeans.add(new PrintInfoBean(new String[]{"D1廚房", "BARRY1"}, new double[]{1}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("", 1)}, 0)); printInfoBeans.add(new PrintInfoBean(new String[]{getLineBorder("", 1)}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{"1","食品名稱"}, new Boolean[]{true}, new double[]{2}, 0)); printInfoBeans.add(new PrintInfoBean(new String[]{"1","食品名稱"}, new Boolean[]{true}, new double[]{2}, 0));
printInfoBeans.add(new PrintInfoBean(new String[]{"1"," 細項名稱"}, new Boolean[]{true}, new double[]{2}, 0)); printInfoBeans.add(new PrintInfoBean(new String[]{"1"," 細項名稱"}, new Boolean[]{true}, new double[]{2}, 0));
...@@ -65,7 +65,7 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH ...@@ -65,7 +65,7 @@ public class PrintTestActivity extends AppCompatActivity implements PrintSocketH
ToastUtils.show(this, "缺紙了"); ToastUtils.show(this, "缺紙了");
} }
mPrinter.initializeObject(GsaCloudApplication.getAppContext(), null); mPrinter.initializeObject(GsaCloudApplication.getAppContext(), null);
mPrinter.putPrintString("192.168.1.203", printInfoBeans); mPrinter.putPrintString("192.168.1.203", 42, printInfoBeans);
// new Thread(() -> { // new Thread(() -> {
// for (int j = 0; j < finalZoomBitmap.size(); j++) { // for (int j = 0; j < finalZoomBitmap.size(); j++) {
......
...@@ -85,11 +85,11 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter ...@@ -85,11 +85,11 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
private void initViewPager() { private void initViewPager() {
List<String> titles = new ArrayList<>(); List<String> titles = new ArrayList<>();
List<Fragment> mFragments = new ArrayList<>(); List<Fragment> mFragments = new ArrayList<>();
if (PrintUtils.isPrintDevice()) { // if (PrintUtils.isPrintDevice()) {
titles.add("本機打印"); titles.add("通用打印設定");
mFragments.add(LocalPrintFragment.newInstance()); mFragments.add(LocalPrintFragment.newInstance());
} // }
titles.add("網絡打印"); titles.add("打印機設定");
ipPrintListActivityFragment = IpPrintListActivityFragment.newInstance(); ipPrintListActivityFragment = IpPrintListActivityFragment.newInstance();
mFragments.add(ipPrintListActivityFragment); mFragments.add(ipPrintListActivityFragment);
...@@ -114,8 +114,13 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter ...@@ -114,8 +114,13 @@ public class PrinterListActivity extends BaseFragmentActivity<PrintListPresenter
topBar.setBackgroundColor(getResources().getColor(R.color.theme_color)); topBar.setBackgroundColor(getResources().getColor(R.color.theme_color));
topBar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener(v -> finish()); topBar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener(v -> finish());
topBar.addRightImageButton(R.drawable.ic_add, R.id.printer_add).setOnClickListener(v -> { topBar.addRightImageButton(R.drawable.ic_add, R.id.printer_add).setOnClickListener(v -> {
if (ipPrintListActivityFragment != null && ipPrintListActivityFragment.isAdded()) { if (mViewPager.getCurrentItem() == 0) {
ipPrintListActivityFragment.startToEditPrint(-1); //添加通用打印
startActivity(new Intent(this, PrintAddCurrencyActivity.class));
} else {
if (ipPrintListActivityFragment != null && ipPrintListActivityFragment.isAdded()) {
ipPrintListActivityFragment.startToEditPrint(-1);
}
} }
}); });
} }
......
...@@ -24,7 +24,7 @@ public class DialogPrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean ...@@ -24,7 +24,7 @@ public class DialogPrinterListAdapter extends BaseQuickAdapter<PrinterDeviceBean
@Override @Override
protected void convert(BaseViewHolder helper, PrinterDeviceBean item) { protected void convert(BaseViewHolder helper, PrinterDeviceBean item) {
helper.setText(R.id.tv_printer_name, item.getIp() + ""); helper.setText(R.id.tv_printer_name, item.getName() + "");
helper.setText(R.id.tv_printer_ip, String.format(mContext.getString(R.string.print_ip), item.getIp())); helper.setText(R.id.tv_printer_ip, String.format(mContext.getString(R.string.print_ip), item.getIp()));
helper.setText(R.id.tv_printer_port, String.format(mContext.getString(R.string.print_port), item.getPort() + "")); helper.setText(R.id.tv_printer_port, String.format(mContext.getString(R.string.print_port), item.getPort() + ""));
} }
......
...@@ -6,13 +6,18 @@ import android.os.Message; ...@@ -6,13 +6,18 @@ import android.os.Message;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Switch; import android.widget.Switch;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.other.SPUtils; import com.gingersoft.gsa.cloud.base.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.constans.PrintConstans; import com.gingersoft.gsa.cloud.constans.PrintConstans;
import com.gingersoft.gsa.cloud.database.bean.PrintCurrencyBean;
import com.gingersoft.gsa.cloud.database.utils.PrintCurrencyDaoUtils;
import com.jess.arms.base.BaseFragment; import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent; import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
...@@ -22,6 +27,10 @@ import com.joe.print.di.component.DaggerLocalPrintComponent; ...@@ -22,6 +27,10 @@ import com.joe.print.di.component.DaggerLocalPrintComponent;
import com.joe.print.di.module.LocalPrintModule; import com.joe.print.di.module.LocalPrintModule;
import com.joe.print.mvp.contract.LocalPrintContract; import com.joe.print.mvp.contract.LocalPrintContract;
import com.joe.print.mvp.presenter.LocalPrintPresenter; import com.joe.print.mvp.presenter.LocalPrintPresenter;
import com.joe.print.mvp.print.PrintUtils;
import com.joe.print.mvp.ui.activity.PrintAddCurrencyActivity;
import java.util.List;
import butterknife.BindView; import butterknife.BindView;
...@@ -33,6 +42,10 @@ import static com.jess.arms.utils.Preconditions.checkNotNull; ...@@ -33,6 +42,10 @@ import static com.jess.arms.utils.Preconditions.checkNotNull;
public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implements LocalPrintContract.View { public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implements LocalPrintContract.View {
@BindView(R2.id.iv_location_print_btn) @BindView(R2.id.iv_location_print_btn)
Switch ivSetLocationPrintBtn; Switch ivSetLocationPrintBtn;
@BindView(R2.id.layout_location_print)
LinearLayout mLayoutLocationPrint;
@BindView(R2.id.layout_currency_content)
LinearLayout currencyContent;
public static LocalPrintFragment newInstance() { public static LocalPrintFragment newInstance() {
LocalPrintFragment fragment = new LocalPrintFragment(); LocalPrintFragment fragment = new LocalPrintFragment();
...@@ -57,13 +70,15 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem ...@@ -57,13 +70,15 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
mPresenter.getPrinterCurrencyList(GsaCloudApplication.getRestaurantId(getActivity()));
initBtn(); initBtn();
} }
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
mLayoutLocationPrint.setVisibility(PrintUtils.isPrintDevice() ? View.VISIBLE : View.GONE);
ivSetLocationPrintBtn.setOnCheckedChangeListener((buttonView, isChecked) -> { ivSetLocationPrintBtn.setOnCheckedChangeListener((buttonView, isChecked) -> {
if(isChecked){ if (isChecked) {
//修改默認打印方式為本地 //修改默認打印方式為本地
SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.LOCAL_PRINT); SPUtils.put(mContext, PrintConstans.DEFAULT_PRINT_METHOD, PrintConstans.LOCAL_PRINT);
ivSetLocationPrintBtn.setChecked(true); ivSetLocationPrintBtn.setChecked(true);
...@@ -151,4 +166,45 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem ...@@ -151,4 +166,45 @@ public class LocalPrintFragment extends BaseFragment<LocalPrintPresenter> implem
public void killMyself() { public void killMyself() {
} }
@Override
public void loadView(List<PrintCurrencyBean> printCurrencyBeans) {
currencyContent.removeAllViews();
PrintCurrencyDaoUtils printCurrencyDaoUtils = new PrintCurrencyDaoUtils(getActivity());
printCurrencyDaoUtils.deleteAll();
if (printCurrencyBeans != null) {
printCurrencyDaoUtils.insertMultPrintCurrencyBean(printCurrencyBeans);
}
if (printCurrencyBeans != null) {
for (int i = 0; i < printCurrencyBeans.size(); i++) {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.print_currency_item, null);
TextView tvType = view.findViewById(R.id.tv_currency_print_type);
TextView tvFoodColor = view.findViewById(R.id.tv_currency_print_food_color);
TextView tvFoodItemColor = view.findViewById(R.id.tv_currency_print_food_items_color);
tvType.setText(printCurrencyBeans.get(i).getType() == 1 ? "堂食" : "外送");
if (printCurrencyBeans.get(i).getFoodComplexion() == 0) {
tvFoodColor.setText("黑色");
} else if (printCurrencyBeans.get(i).getFoodComplexion() == 1) {
tvFoodColor.setText("紅色");
} else if (printCurrencyBeans.get(i).getFoodComplexion() == 3) {
tvFoodColor.setText("綠色");
}
tvFoodItemColor.setText(printCurrencyBeans.get(i).getModifierComplexion() == 0 ? "黑色" : "紅色");
view.findViewById(R.id.iv_currency_print_delete).setOnClickListener(v -> {
//刪除
});
int finalI = i;
view.setOnClickListener(v->{
//編輯
Intent intent = new Intent(mContext, PrintAddCurrencyActivity.class);
intent.putExtra("printCurrencyBean", printCurrencyBeans.get(finalI));
startActivity(intent);
});
currencyContent.addView(view);
}
}
}
} }
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_location_print"
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView <TextView
android:layout_width="wrap_content" style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="默認本機打印" />
<Switch
android:id="@+id/iv_location_print_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumb="@drawable/shape_thumb_on"
android:track="@drawable/selector_switch_track" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20" android:paddingTop="@dimen/dp_10"
android:text="設置默認打印為本機打印" android:paddingBottom="@dimen/dp_10"
android:textColor="@color/theme_333_color" style="@style/print_add_printer_input_style"
android:textSize="@dimen/dp_16" android:layout_width="match_parent"
app:layout_constraintBottom_toBottomOf="@id/iv_location_print_btn" android:gravity="center_vertical"
app:layout_constraintLeft_toLeftOf="parent" android:orientation="horizontal">
app:layout_constraintTop_toTopOf="@id/iv_location_print_btn" />
<TextView
style="@style/print_currency_title_textStyle"
<Switch android:layout_width="0dp"
android:id="@+id/iv_location_print_btn" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_weight="1"
android:text="類型" />
<TextView
style="@style/print_currency_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="食品顏色" />
<TextView
style="@style/print_currency_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="細項顏色" />
<TextView
style="@style/print_currency_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="操作" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
<LinearLayout
android:id="@+id/layout_currency_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_20" android:orientation="vertical"/>
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
style="@style/print_add_printer_input_style"
android:layout_width="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_currency_print_type"
style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="堂食" />
<TextView
android:id="@+id/tv_currency_print_food_color"
style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="黑色" />
<TextView
android:id="@+id/tv_currency_print_food_items_color"
style="@style/print_add_title_textStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="紅色" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/ic_edit" />
<ImageView
android:id="@+id/iv_currency_print_delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="@dimen/dp_10"
android:src="@drawable/ic_delete" />
</LinearLayout>
</LinearLayout>
<include layout="@layout/include_horizontal_color_ccc_dividing_line" />
</LinearLayout>
\ No newline at end of file
...@@ -52,4 +52,9 @@ ...@@ -52,4 +52,9 @@
<item name="android:textSize">@dimen/dp_16</item> <item name="android:textSize">@dimen/dp_16</item>
<item name="android:textColor">@color/normal_color</item> <item name="android:textColor">@color/normal_color</item>
</style> </style>
<style name="print_currency_title_textStyle">
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:textColor">@color/theme_color</item>
</style>
</resources> </resources>
\ No newline at end of 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