Commit 9d1b9379 by Wyh

凍鏈接單優化,打印回調優化

parent 25817e40
......@@ -12,15 +12,14 @@ import com.gingersoft.coldchain_module.mvp.model.bean.PickUpBean;
import com.gingersoft.coldchain_module.mvp.model.bean.ShipAnyOrdersNewBean;
import com.gingersoft.coldchain_module.mvp.model.bean.SupplementInfoBean;
import com.gingersoft.coldchain_module.mvp.model.bean.ThirdItem;
import com.gingersoft.coldchain_module.mvp.model.bean.UpdateOrderStatusBean;
import com.gingersoft.coldchain_module.mvp.model.bean.UpdateRestaurantStateBean;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.constans.PrintConstans;
import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.order.order.TakeawayOrder;
......@@ -330,6 +329,8 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
third.add(thirdItemItem);
}
}
Log.e("eee", "調用第三方物流接口開始");
//第三方物流
RequestBody requestBody = new FormBody.Builder()
.add("orderId", dataBean.getID() + "")
.add("items", GsonUtils.GsonString(third))
......@@ -346,6 +347,7 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
.subscribe(new ErrorHandleSubscriber<ShipAnyOrdersNewBean>(mErrorHandler) {
@Override
public void onNext(@NonNull ShipAnyOrdersNewBean info) {
Log.e("eee", "調用第三方物流接口結束:");
if (info != null && info.isSuccess()) {
//修改訂單狀態
updateOrderState(dataBean, ColdChainConstants.ORDER_CONFIRMED);
......@@ -355,13 +357,14 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
}
private void printColdChainOrder(OrderDetails.DataBean dataBean) {
LogUtil.w("eee", "凍鏈自動上菜紙" + RestaurantExpandInfoUtils.getValue(ExpandConstant.AutoPrinterPaper, true));
if (RestaurantExpandInfoUtils.getValue(ExpandConstant.AutoPrinterPaper, true)) {
//打印凍鏈上菜紙
dataBean.setOrder_type(8);
TakeawayOrder.getInstance().getShoppingCart().setDeliveryAndPickupData(dataBean);
PrintContentAdapter contentAdapter = new PrintContentAdapter();
PrintContent printContent = contentAdapter.adaptationPrintTakeawayFormContent(dataBean);
Log.e("eee", "打印凍鏈上菜紙");
LogUtil.w("eee", "打印凍鏈上菜紙");
CC.obtainBuilder(ComponentName.COMPONENT_PRINT)
.addParam(PrintConstans.PRINT_TYPE, PrintConstans.PRINT_OTHER_ORDER)
.addParam(PrintConstans.PRINT_CONTENT, printContent)
......@@ -390,27 +393,34 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
}
//添加PRJ
addPrj(dataBean);
RequestBody requestBody = new FormBody.Builder()
.add("memberId", UserContext.newInstance().getMemberId() + "")
.add("orderId", dataBean.getID() + "")
.add("status", status + "")
.add("", UserContext.newInstance().getMemberName())
.build();
mModel.updateOrderStatus(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("確認訂單中,請稍候..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<UpdateOrderStatusBean>(mErrorHandler) {
@Override
public void onNext(@NonNull UpdateOrderStatusBean info) {
mRootView.refreshOrderState(dataBean.getID());
//打印凍鏈上菜紙
printColdChainOrder(dataBean);
}
});
//打印凍鏈上菜紙
printColdChainOrder(dataBean);
//修改訂單狀態
//後台會修改狀態,這裡就不修改
// RequestBody requestBody = new FormBody.Builder()
// .add("memberId", UserContext.newInstance().getMemberId() + "")
// .add("orderId", dataBean.getID() + "")
// .add("status", status + "")
// .add("", UserContext.newInstance().getMemberName())
// .build();
// LogUtil.w("eee", "修改訂單狀態開始----start");
// mModel.updateOrderStatus(requestBody)
// .subscribeOn(Schedulers.io())
// .doOnSubscribe(disposable -> mRootView.showLoading("確認訂單中,請稍候..."))
// .subscribeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread())
// .doAfterTerminate(() -> mRootView.hideLoading())
// .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
// .subscribe(new ErrorHandleSubscriber<UpdateOrderStatusBean>(mErrorHandler) {
// @Override
// public void onNext(@NonNull UpdateOrderStatusBean info) {
// LogUtil.w("eee", "修改訂單狀態結束----end----" + info.toString());
// mRootView.refreshOrderState(dataBean.getID());
// //打印凍鏈上菜紙
// printColdChainOrder(dataBean);
// }
// });
}
private void addPrj(OrderDetails.DataBean dataBean) {
......@@ -439,6 +449,7 @@ public class ColdChainMainPresenter extends BasePresenter<ColdChainMainContract.
.add("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId() + "")
.add("orderDetailsIds", ids.toString())
.build();
LogUtil.i("eee", "添加prj");
Disposable subscribe = mModel.addPrj(requestBody)
.subscribeOn(Schedulers.io()).subscribe(s -> {
});
......
......@@ -40,7 +40,7 @@ import com.gingersoft.gsa.cloud.common.constans.DeliveryPickConstans;
import com.gingersoft.gsa.cloud.common.constans.ExpandConstant;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService;
import com.gingersoft.gsa.cloud.common.service.DataNotificationService;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
......@@ -53,7 +53,6 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.popup.QMUIPopup;
import com.qmuiteam.qmui.widget.popup.QMUIPopups;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import java.lang.reflect.Method;
import java.util.ArrayList;
......@@ -62,7 +61,6 @@ import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.disposables.Disposable;
import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -207,7 +205,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
private void initService() {
//開啟websocket
Intent intent = new Intent(getApplicationContext(), GetInfoUpdateService.class);
Intent intent = new Intent(getApplicationContext(), DataNotificationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
} else {
......@@ -222,28 +220,33 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
registerReceiver(clearHeartBroadcastReceiver, intentFilter);
}
private GetInfoUpdateService.MyBind bind = null;
private DataNotificationService.MyBind bind = null;
private long lastClickTime = 0;
private ServiceConnection serviceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
bind = (GetInfoUpdateService.MyBind) service;
bind = (DataNotificationService.MyBind) service;
if (bind != null) {
bind.setOnPostCallBack(type -> {
// -1斷開連接,\n-2:消息傳輸錯誤,\n0:連接消息,\n1:登錄通知,\n2:登出通知,\n3:外賣送單通知,\n4:自取送單通知,\n5:歷史訂單通知,\n6:修改訂單狀態通知,\n7:支付成功通知"
if (type == 3 || type == 5
|| type == 6 || type == 7) {//ColdChainConstants.orderType
|| type == 6 || type == 7) {
long nowTime = System.currentTimeMillis();
if (nowTime - lastClickTime < 8000) {
return;
}
lastClickTime = nowTime;
fragments.get(viewPager.getCurrentItem()).onRefreshData();
mPresenter.getBalance();
if (type != 5) {
getNumByOrderTypeInvoke("loadNumber");
}
//判斷要不要自動接單
if(autoReceivingOrders.isChecked()){
if (autoReceivingOrders.isChecked()) {
mPresenter.startToBeConfirmedOrderList(restaurantId);
}
}
if (type == 3 || type == 6 || type == 7) {
getNumByOrderTypeInvoke("loadNumber");
}
});
bind.execute(aBoolean -> null);
bind.setJumpActivity(ColdChainMainActivity.class);
......@@ -255,7 +258,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
}
};
private int confirmedOrderNum;
@Override
......
......@@ -28,7 +28,7 @@
</intent-filter>
</activity>
<service android:name="com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService" />
<service android:name="com.gingersoft.gsa.cloud.common.service.DataNotificationService" />
<meta-data
android:name="com.gingersoft.gsa.cloud.common.config.globalconfig.GlobalConfiguration"
......
......@@ -7,7 +7,7 @@ import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService;
import com.gingersoft.gsa.cloud.common.service.DataNotificationService;
import com.gingersoft.gsa.delivery_pick_mode.data.network.ServiceCreator;
import com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.PrjQueryActivity;
import com.gingersoft.gsa.delivery_pick_mode.mvp.ui.activity.SendOrderActivity;
......@@ -52,7 +52,7 @@ public class DeliveryPickComponent implements IComponent {
CC.sendCCResult(cc.getCallId(), CCResult.success());
break;
case "closeHeart":
Intent intent = new Intent(cc.getContext(), GetInfoUpdateService.class);
Intent intent = new Intent(cc.getContext(), DataNotificationService.class);
cc.getContext().stopService(intent);
break;
case "historyActivity":
......
......@@ -22,7 +22,7 @@ import com.gingersoft.gsa.cloud.common.core.delivery.OrderDetails.Companion.veri
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager
import com.gingersoft.gsa.cloud.common.core.user.UserContext
import com.gingersoft.gsa.cloud.common.logan.LoganManager
import com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService
import com.gingersoft.gsa.cloud.common.service.DataNotificationService
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil
......@@ -232,7 +232,8 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} else {
}
} else {}
} else {
}
}
//獲取預約單
repository.requestOrderList(restaurantId.toString(), fragmentStatus[1], fragmentType[0], "1", orderNo, phone, 1).apply {
......@@ -420,11 +421,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
thirdSend(restaurantId, dataBean, trafficType, status, isPrintPrj, isPrintBill, listener)
}
}
}, {
}, { e ->
listener.invoke(getMsgBean(0, "", false))
it.printStackTrace()
GetInfoUpdateService.loginfo.append("錯誤信息111:" + it.message + " LOCALIZEDMESSAGE:" + it.localizedMessage + it.cause)
GetInfoUpdateService.loginfo.append("\n")
e.printStackTrace()
DataNotificationService.loginfo.append("錯誤信息111:" + e.message + " LOCALIZEDMESSAGE:" + e.localizedMessage + e.cause)
DataNotificationService.loginfo.append("\n")
})
}
......@@ -564,12 +565,12 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
//添加PRJ
//單獨包起來,哪怕這接口報錯也不要影響到正常的邏輯
repository.addPrj(dataBean.Order_ID.toString(), restaurantId.toString(), ids.toString())
GetInfoUpdateService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString())
GetInfoUpdateService.loginfo.append("\n")
DataNotificationService.loginfo.append("添加PRJ:orderId:" + dataBean.Order_ID.toString() + "restaurantId:" + restaurantId + "orderDetailsIds:" + ids.toString())
DataNotificationService.loginfo.append("\n")
}, {
it.printStackTrace()
GetInfoUpdateService.loginfo.append("錯誤信息222:" + it.message + " LOCALIZEDMESSAGE:" + it.localizedMessage + it.cause)
GetInfoUpdateService.loginfo.append("\n")
DataNotificationService.loginfo.append("錯誤信息222:" + it.message + " LOCALIZEDMESSAGE:" + it.localizedMessage + it.cause)
DataNotificationService.loginfo.append("\n")
})
}
if (isPrintBill) {
......
......@@ -31,7 +31,7 @@ import com.gingersoft.gsa.cloud.common.constans.ExpandConstant
import com.gingersoft.gsa.cloud.common.constans.FoodSummaryConstans.TAKEAWAY_TYPE
import com.gingersoft.gsa.cloud.common.constans.FunctionManagerConstants
import com.gingersoft.gsa.cloud.common.function.FunctionManager
import com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService
import com.gingersoft.gsa.cloud.common.service.DataNotificationService
import com.gingersoft.gsa.cloud.common.service.PostCallBack
import com.gingersoft.gsa.cloud.order.order.BaseOrder
import com.gingersoft.gsa.cloud.ui.utils.AppDialog
......@@ -387,7 +387,7 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
private fun initWebsocket() {
//開啟websocket
val service = Intent(applicationContext, GetInfoUpdateService::class.java)
val service = Intent(applicationContext, DataNotificationService::class.java)
val notification: NotificationManagerCompat = NotificationManagerCompat.from(this)
if (!notification.areNotificationsEnabled()) {
//未開啟通知權限
......@@ -437,12 +437,12 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
unbindService(serviceConnection)
}
var bind: GetInfoUpdateService.MyBind? = null
var bind: DataNotificationService.MyBind? = null
var lastRefreshTime: Long = 0
private var serviceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) {
bind = service as GetInfoUpdateService.MyBind
bind = service as DataNotificationService.MyBind
bind?.let { it ->
it.setOnPostCallBack(object : PostCallBack {
override fun callBack(type: Int) {
......
......@@ -3,7 +3,7 @@ package com.gingersoft.gsa.delivery_pick_mode.ui.activity;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.gingersoft.gsa.cloud.common.service.GetInfoUpdateService;
import com.gingersoft.gsa.cloud.common.service.DataNotificationService;
import com.gingersoft.gsa.delivery_pick_mode.R;
public class LogActivity extends AppCompatActivity {
......@@ -14,13 +14,13 @@ public class LogActivity extends AppCompatActivity {
setContentView(R.layout.activity_log);
loadInfo();
findViewById(R.id.btn_clear_log).setOnClickListener(v -> {
GetInfoUpdateService.loginfo.setLength(0);
DataNotificationService.loginfo.setLength(0);
loadInfo();
});
findViewById(R.id.btn_back).setOnClickListener(v ->finish());
}
private void loadInfo() {
((TextView) findViewById(R.id.tv_log)).setText(GetInfoUpdateService.loginfo.toString());
((TextView) findViewById(R.id.tv_log)).setText(DataNotificationService.loginfo.toString());
}
}
package com.joe.print.mvp.print;
public interface PrintListener {
void printStateChanged(int state);
void printSuccess();
void printFailure(String msg);
}
......@@ -5,8 +5,8 @@ import android.text.TextUtils;
import android.util.Xml;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.printer.plugins.PrinterPlugins;
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils;
import com.joe.print.mvp.print.PrintListener;
import com.joe.print.mvp.ui.activity.PrintActivity;
import org.xmlpull.v1.XmlPullParser;
......@@ -15,11 +15,8 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.ConnectException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.TimeoutException;
......@@ -43,7 +40,6 @@ public class BBposPrint {
* RESULT_UNKNOWN_MERCHANT : -7
* RESULT_INPUT_INVALID : -8
*/
private static final String RESULT_OK = "RESULT_OK"; //成功
private static final String RESULT_FAILED = "RESULT_FAILED";//失敗
private static final String RESULT_CANCELED = "RESULT_CANCELED";//取消
......@@ -84,10 +80,9 @@ public class BBposPrint {
* 递归打印
*
* @param printDatas 打印数据
* @param listener 回调监听
* @param recursion 是否递归从队列中取打印数据
*/
public void print(String[] printDatas, PrintListener listener, boolean recursion) {
public void print(String[] printDatas, boolean recursion) {
if (!recursion) {
if (printXMLQueues.size() > 0) {
printXMLQueues.clear();
......@@ -117,7 +112,7 @@ public class BBposPrint {
@Override
public void onNext(String s) {
try {
Map<String, String> xmlContentMaps = analysisPrintResult(s, printDatas, listener, recursion);
Map<String, String> xmlContentMaps = analysisPrintResult(s, printDatas, recursion);
String status = xmlContentMaps.get(STATUS);
if (status != null && status.equals("SUCCESS")) {
printSuccesCount++;
......@@ -125,13 +120,13 @@ public class BBposPrint {
String errorMessage = xmlContentMaps.get("ErrorMessage");
if (!TextUtils.isEmpty(errorMessage)) {
if (errorMessage.equals(HTML_FORMAT_ERR)) {
listener.printFailure("內容格式錯誤,無法打印!");
printFailure("內容格式錯誤,無法打印!", 0);
backPrintActivity();
return;
} else if (s.contains("Please login first")) {
login(printDatas, listener, recursion);
login(printDatas, recursion);
} else {
listener.printFailure(errorMessage);
printFailure(errorMessage, 0);
}
}
printErrorCount++;
......@@ -139,11 +134,10 @@ public class BBposPrint {
} catch (XmlPullParserException | IOException e) {
e.printStackTrace();
if (s.contains("Failed to connect")) {
listener.printFailure("無法連接打印,請檢查WisePay是否打開");
printFailure("無法連接打印,請檢查WisePay是否打開", 0);
backPrintActivity();
return;
} else if (s.contains("Please login first")) {
login(printDatas, listener, recursion);
login(printDatas, recursion);
}
}
}
......@@ -153,38 +147,38 @@ public class BBposPrint {
public void onError(Throwable e) {
e.printStackTrace();
if (e instanceof ConnectException) {
listener.printFailure("無法連接打印,請檢查WisePay是否打開");
printFailure("無法連接打印,請檢查WisePay是否打開", 0);
backPrintActivity();
return;
} else if (e instanceof TimeoutException) {
listener.printFailure("已超時");
printFailure("已超時", 0);
}
printErrorCount++;
maxRecursionCount--;
printBefore(printDatas,listener);
printBefore(printDatas);
}
@Override
public void onComplete() {
maxRecursionCount--;
printBefore(printDatas,listener);
printBefore(printDatas);
}
});
}
private void printBefore(String[] printDatas,PrintListener listener){
private void printBefore(String[] printData) {
int totalCount = printSuccesCount + printErrorCount;
if (totalCount == printXMLQueues.size()) {
//打印完畢
if (printSuccesCount > 0 && printErrorCount > 0) {
//部分打印失敗
listener.printFailure("打印成功" + printSuccesCount + "張,失敗" + printErrorCount + "張");
printFailure("打印成功" + printSuccesCount + "張,失敗" + printErrorCount + "張", 0);
} else if (printSuccesCount > 0) {
listener.printSuccess();
printSuccess();
}
backPrintActivity();
}else {
printNext(printDatas, listener);
} else {
printNext(printData);
}
}
......@@ -192,10 +186,9 @@ public class BBposPrint {
* 登录bbpos
*
* @param printDatas
* @param listener
* @param recursion
*/
public void login(String[] printDatas, PrintListener listener, boolean recursion) {
public void login(String[] printDatas, boolean recursion) {
OkHttp3Utils.get("http://localhost:8080/pos?UserName=gs01&Password=88888888&transactionType=LOGIN&isExternal=true&apiVersion=21")
.subscribeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
......@@ -208,14 +201,14 @@ public class BBposPrint {
@Override
public void onNext(String s) {
//登录成功 开始打印
print(printDatas, listener, recursion);
print(printDatas, recursion);
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
if (e instanceof ConnectException) {
listener.printFailure("登錄失敗,無法打印!");
printFailure("登錄失敗,無法打印!", 0);
}
}
......@@ -235,7 +228,7 @@ public class BBposPrint {
GsaCloudApplication.getAppContext().startActivity(intent);
}
private Map<String, String> analysisPrintResult(String s, String[] printDatas, PrintListener listener, boolean recursion) throws XmlPullParserException, IOException {
private Map<String, String> analysisPrintResult(String s, String[] printDatas, boolean recursion) throws XmlPullParserException, IOException {
XmlPullParser xmlPullParser = Xml.newPullParser();
xmlPullParser.setInput(new ByteArrayInputStream(s.getBytes()), "utf-8");
int eventType = xmlPullParser.getEventType();
......@@ -279,11 +272,11 @@ public class BBposPrint {
return xmlContents;
}
private void printNext(String[] printDatas, PrintListener listener) {
private void printNext(String[] printData) {
//打印完一張就移除
printXMLQueues.remove();
//递归进行打印
print(printDatas, listener, true);
print(printData, true);
}
private void closePrintObservable() {
......@@ -292,4 +285,13 @@ public class BBposPrint {
stringObservable = null;
}
}
private void printSuccess() {
PrinterPlugins.getOnPrinterFlowHandler().onPrintSuccess();
}
private void printFailure(String msg, int code) {
PrinterPlugins.getOnPrinterFlowHandler().onPrintError(new Exception(msg), code);
}
}
......@@ -4,7 +4,9 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
......@@ -13,6 +15,7 @@ import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import com.airbnb.lottie.LottieAnimationView;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.ui.widget.dialog.BaseRetryDialog;
import com.joe.print.R;
import com.qmuiteam.qmui.layout.QMUILinearLayout;
......@@ -64,13 +67,13 @@ public class PrinterLoadingDialog extends BaseRetryDialog {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setCanceledOnTouchOutside(true);
}
@Override
public void show() {
super.show();
LogUtil.d("PrinterLoadingDialog", "show");
}
@Override
......@@ -107,8 +110,17 @@ public class PrinterLoadingDialog extends BaseRetryDialog {
return view;
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Log.e("PrinterLoadingDialog", "onAttachedToWindow");
}
public void setStep(int step, int status, String errorMsg) {
tvGeneratePrintData.post(() -> {
LogUtil.d("PrinterLoadingDialog", "進入setStep:" + step + "--status:" + status + "線程:" + Thread.currentThread().getId() + "/" + Looper.getMainLooper().getThread().getId());
tvErrorMsg.post(() -> {
LogUtil.d("PrinterLoadingDialog-", "--start----setStep:" + step + "--status:" + status);
if (!TextUtils.isEmpty(errorMsg)) {
tvErrorMsg.setText(errorMsg);
tvErrorMsg.setVisibility(View.VISIBLE);
......@@ -127,6 +139,7 @@ public class PrinterLoadingDialog extends BaseRetryDialog {
});
}
private void setStatusResult(int step, int status) {
switch (step) {
case PrinterLoadingDialog.PROGRESS_PRINTING:
......@@ -149,6 +162,7 @@ public class PrinterLoadingDialog extends BaseRetryDialog {
}
break;
default:
LogUtil.d("PrinterLoadingDialog", "default----setStatusResult");
break;
}
}
......
......@@ -12,7 +12,7 @@ import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.SendSupplierMsgBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.utils.DoubleClickUtils;
import com.gingersoft.gsa.cloud.common.utils.DoubleClickUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......
......@@ -327,13 +327,10 @@ class OrderDetails {
}
}
}
Log.e("eee", "食品總金額$foodAmount")
//食品金額加上餐盒費,配送費,應該等於總金額
foodAmount = MoneyUtil.sum(MoneyUtil.sum(foodAmount, orderDetail.Lunchbox), orderDetail.DELIVERY_CHARGE)
Log.e("eee", "總金額$foodAmount")
//後台返回的總金額與計算的總金額相減,如果不等於0,則是金額有問題,攔截
var differenceAmount = MoneyUtil.sub(MoneyUtil.sub(totalAmount, foodAmount), allowableError)
Log.e("eee", "金額差$differenceAmount")
differenceAmount = abs(differenceAmount)
if (MoneyUtil.compareTo(differenceAmount, allowableError) == 1) {
return true
......@@ -345,11 +342,9 @@ class OrderDetails {
payAmount = MoneyUtil.sub(payAmount, coupon.discount_amount)
}
}
Log.e("eee", "減去折扣之後的總金額$payAmount")
//計算折扣後的金額,減去支付金額,如果不為0,則是有問題
differenceAmount = MoneyUtil.sub(MoneyUtil.sub(payAmount, orderDetail.PAY_AMOUNT), allowableError)
Log.e("eee", "支付金額差$differenceAmount")
differenceAmount = abs(differenceAmount)
if (MoneyUtil.compareTo(differenceAmount, allowableError) == 1) {
return true
......
......@@ -31,10 +31,10 @@ public class RestaurantInfoManager {
if (restaurantInfo == null) {
restaurantInfo = new RestaurantInfo();
}
brandInfo.setBrandId((Integer) SPUtils.get(UserConstans.brandId, 1));
brandInfo.setBrandId((Integer) SPUtils.get(UserConstans.brandId, 0));
brandInfo.setBrandName((String) SPUtils.get(UserConstans.brandName, ""));
restaurantInfo.setGsPosShopId((String) SPUtils.get(UserConstans.gsPosShopId, "-1"));
restaurantInfo.setRestaurantId((Integer) SPUtils.get(UserConstans.restaurantId, 26));
restaurantInfo.setRestaurantId((Integer) SPUtils.get(UserConstans.restaurantId, 0));
restaurantInfo.setRestaurantName((String) SPUtils.get(UserConstans.restaurantName, ""));
}
......
package com.gingersoft.gsa.cloud.common.service
import android.annotation.SuppressLint
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
......@@ -15,16 +14,13 @@ import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import android.util.Log
import android.view.View
import android.widget.RemoteViews
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import com.billy.cc.core.component.CC
import com.billy.cc.core.component.CCResult
import com.gingersoft.gsa.cloud.common.R
import com.gingersoft.gsa.cloud.common.constans.AppConstans
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans
import com.gingersoft.gsa.cloud.common.constans.PrintConstans
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager
import com.gingersoft.gsa.cloud.common.core.user.UserContext
import com.gingersoft.gsa.cloud.common.logan.LoganManager
......@@ -129,9 +125,10 @@ class DataNotificationService : Service() {
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
//获取当前长连类型
mCurrConnectionType = intent!!.getIntExtra(CONNECTION_TYPE, OPEN_DELIVET_ORDER_CONNECTION)
intent?.let {
mCurrConnectionType = it.getIntExtra(CONNECTION_TYPE, OPEN_DELIVET_ORDER_CONNECTION)
}
initNotification()
......
package com.gingersoft.supply_chain.mvp.utils;
package com.gingersoft.gsa.cloud.common.utils;
import android.util.Log;
import android.view.View;
import com.gingersoft.gsa.cloud.app.GsaCloudApplication;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
/**
......@@ -15,12 +19,42 @@ public class DoubleClickUtils {
public static boolean isFastDoubleClick() {
long nowTime = System.currentTimeMillis();
if (nowTime - lastClickTime < 500) {//500ms
ToastUtils.show(GsaCloudApplication.getAppContext(), "請慢一點");
if (nowTime - lastClickTime < 1000) {//500ms
LogUtil.w("eee", "間隔小於1000");
// ToastUtils.show(GsaCloudApplication.getAppContext(), "請慢一點");
return true;
}
lastClickTime = nowTime;
return false;
}
/**
* 最近一次点击的时间
*/
private static long mLastClickTime;
/**
* 最近一次点击的控件ID
*/
private static int mLastClickViewId;
/**
* 是否是快速点击
*
* @param v 点击的控件
* @param intervalMillis 时间间期(毫秒)
* @return true:是,false:不是
*/
public static boolean isFastDoubleClick(View v, long intervalMillis) {
int viewId = v.getId();
long time = System.currentTimeMillis();
long timeInterval = Math.abs(time - mLastClickTime);
if (timeInterval < intervalMillis && viewId == mLastClickViewId) {
return true;
} else {
mLastClickTime = time;
mLastClickViewId = viewId;
return false;
}
}
}
......@@ -87,6 +87,29 @@ public class UpdateBean {
*/
public static final int FAIL_LOCAL_PRINT_NOT_DEVICE = 17;
/**
* 18 USB打印失敗,未添加到後台
*/
public static final int FAIL_USB_PRINT = 18;
/**
* 19 未找到USB打印機,未添加到後台
*/
public static final int FAIL_USB_PRINT_NOT_FIND = 19;
/**
* 20 生成打印數據失敗
*/
public static final int FAIL_GENERATE_PRINT_INFO = 20;
/**
* 505 SUNMI未查詢到打印機請查詢打印管理配置是否正確
* 通過打印位置沒有找到對應的打印機
*/
......
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