Browse Source

1、物料监控
2、修复优惠码无法正常使用问题
3、修复快速点击会导致多个弹窗显示问题

ccc 1 month ago
parent
commit
4266b243c5

+ 46 - 33
app/src/main/java/com/bgy/autosale/RemoteSupportService.java

@@ -159,7 +159,7 @@ public class RemoteSupportService extends Service implements SendCallback {
             }
         }, 20000);
 
-        if (Hawk.get(Name.AUTOUPLOADORDER, false)) {
+        if (Hawk.get(Name.AUTOUPLOADORDER, true)) {
             upCoinOrder();
         }
     }
@@ -290,6 +290,15 @@ public class RemoteSupportService extends Service implements SendCallback {
     public void event(ApiMessageEvent messageEvent) {
         Log.d(TAG, "Service event: ApiMessageEvent" + messageEvent.getName());
         switch (messageEvent.getName()) {
+            case Name.MATERIEL:
+                String isOpen = (String) messageEvent.getData();
+                if (isOpen.equals("1")){
+                    stopMateriel();
+                    startMateriel();
+                }else {
+                    stopMateriel();
+                }
+                break;
             case "statusType1":
                 //同步数据
                 //showSyncDialog();
@@ -996,6 +1005,7 @@ public class RemoteSupportService extends Service implements SendCallback {
 
     private IView view;
     private HashMap<String, Double> materielMap;
+
     /**
      * 发送心跳
      */
@@ -1142,7 +1152,7 @@ public class RemoteSupportService extends Service implements SendCallback {
             Log.e(TAG, "checkHeartData: 开始心跳2");
             stopHeartbeat();
             startHeartbeat();
-            if (Hawk.get(Name.MATERIEL,false)){
+            if (Hawk.get(Name.MATERIEL, false)) {
                 stopMateriel();
                 startMateriel();
             }
@@ -1151,28 +1161,30 @@ public class RemoteSupportService extends Service implements SendCallback {
             Logger.i(TAG + "系统管理id为空");
         }
     }
+
     private Timer timerMateriel;
     private TimerTask taskMateriel;
-    private boolean C01Type=false;
-    private boolean C02Type=false;
-    private boolean J01Type=false;
-    private boolean J02Type=false;
-    private boolean J03Type=false;
-
-    private void startMateriel(){
+    private boolean C01Type = false;
+    private boolean C02Type = false;
+    private boolean J01Type = false;
+    private boolean J02Type = false;
+    private boolean J03Type = false;
+
+    private void startMateriel() {
+        Log.d(TAG, "startMateriel: 1");
         timerMateriel = new Timer();
         taskMateriel = new TimerTask() {
             @Override
             public void run() {
                 materielMap = Hawk.get(Name.MATERIEL_PARAM, Global.defaultMaterielMap());
-                double C01= materielMap.get("C01");
-                double C02= materielMap.get("C02");
-                double J01= materielMap.get("J01");
-                double J02= materielMap.get("J02");
-                double J03= materielMap.get("J03");
-                if ( C01<= 20) {
+                double C01 = materielMap.get("C01");
+                double C02 = materielMap.get("C02");
+                double J01 = materielMap.get("J01");
+                double J02 = materielMap.get("J02");
+                double J03 = materielMap.get("J03");
+                if (C01 <= 20) {
                     if (!C01Type) {
-                        setErrorMateriel(21, App.app.getString(R.string.nutletless1)+C01+"%", "1");
+                        setErrorMateriel(21, "No.32" + App.app.getString(R.string.nutletless1) + C01 + "%", "1");
                         C01Type = true;
                     }
                 } else {
@@ -1181,7 +1193,7 @@ public class RemoteSupportService extends Service implements SendCallback {
 
                 if (C02 <= 20) {
                     if (!C02Type) {
-                        setErrorMateriel(22, App.app.getString(R.string.nutletless2)+C02+"%", "1");
+                        setErrorMateriel(22, "No.33" +App.app.getString(R.string.nutletless2) + C02 + "%", "1");
                         C02Type = true;
                     }
                 } else {
@@ -1190,16 +1202,16 @@ public class RemoteSupportService extends Service implements SendCallback {
 
                 if (J01 <= 20) {
                     if (!J01Type) {
-                        setErrorMateriel(23, App.app.getString(R.string.jamless1)+J01+"%", "1");
+                        setErrorMateriel(23, "No.34" +App.app.getString(R.string.jamless1) + J01 + "%", "1");
                         J01Type = true;
                     }
                 } else {
                     J01Type = false;
                 }
 
-                if (J02<= 20) {
+                if (J02 <= 20) {
                     if (!J02Type) {
-                        setErrorMateriel(24, App.app.getString(R.string.jamless2)+J02+"%", "1");
+                        setErrorMateriel(24, "No.35" +App.app.getString(R.string.jamless2) + J02 + "%", "1");
                         J02Type = true;
                     }
                 } else {
@@ -1208,7 +1220,7 @@ public class RemoteSupportService extends Service implements SendCallback {
 
                 if (J03 <= 20) {
                     if (!J03Type) {
-                        setErrorMateriel(25, App.app.getString(R.string.jamless3)+J03+"%", "1");
+                        setErrorMateriel(25, "No.36" +App.app.getString(R.string.jamless3) + J03 + "%", "1");
                         J03Type = true;
                     }
                 } else {
@@ -1216,20 +1228,21 @@ public class RemoteSupportService extends Service implements SendCallback {
                 }
             }
         };
-        timerMateriel.schedule(taskMateriel, 1000, 1000);
+        timerMateriel.schedule(taskMateriel, 1000, 1000 * 60 * 3);
     }
+
     public void setErrorMateriel(int key, String reason, String level) {
-            long date = System.currentTimeMillis();
-            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            Date curDate = new Date(date);
-            String time = formatter.format(curDate);
-            AddAlarmRecordBean addAlarmRecordBean = new AddAlarmRecordBean(reason, Heartbeat.deviceId, time, "", level);
-            Gson gson = new Gson();
-            String json = gson.toJson(addAlarmRecordBean);
-            RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
-            if (!Constant.reasonKey.equals(reason)) {
-                upError(body, 0, reason);
-            }
+        long date = System.currentTimeMillis();
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date curDate = new Date(date);
+        String time = formatter.format(curDate);
+        AddAlarmRecordBean addAlarmRecordBean = new AddAlarmRecordBean(reason, Heartbeat.deviceId, time, "", level);
+        Gson gson = new Gson();
+        String json = gson.toJson(addAlarmRecordBean);
+        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
+        if (!Constant.reasonKey.equals(reason)) {
+            upError(body, 0, reason);
+        }
     }
 
     private void stopMateriel() {

+ 10 - 8
app/src/main/java/com/bgy/autosale/payutil/dialog/ShoppingTrolleyDialogChoosePay.java

@@ -29,6 +29,7 @@ import com.bgy.autosale.utils.ToastUtil;
 import com.google.gson.Gson;
 import com.hboxs.base_library.callback.DialogClickListener;
 import com.hboxs.base_library.constant.Name;
+import com.hboxs.base_library.util.PreventSpeedClickUtil;
 import com.hboxs.base_library.util.UiUtil;
 import com.orhanobut.hawk.Hawk;
 
@@ -49,7 +50,7 @@ public class ShoppingTrolleyDialogChoosePay extends FrameLayout implements View.
     private boolean canTouchOutsideDismiss = true;
     ImageView ivNayax;
     private LinearLayout llDiscountsCode;
-    private boolean showCash= Hawk.get(Name.CASH_PAY,true);
+    private boolean showCash = Hawk.get(Name.CASH_PAY, true);
     private static final String TAG = "ShoppingTrolleyDialogCh";
 
     public void setListener(DialogClickListener listener) {
@@ -73,15 +74,15 @@ public class ShoppingTrolleyDialogChoosePay extends FrameLayout implements View.
         } else if (App.app.payChannel == Constant.PAY_ONLINE_AND_PRICE_MODEL) {
             view.findViewById(R.id.iv_qr_code).setOnClickListener(this);
             view.findViewById(R.id.iv_qr_code).setVisibility(VISIBLE);
-        }else if (App.app.payChannel ==  Constant.GKash){
+        } else if (App.app.payChannel == Constant.GKash) {
             view.findViewById(R.id.iv_mlxy_gkash).setOnClickListener(this);
             view.findViewById(R.id.iv_mlxy_gkash).setVisibility(VISIBLE);
             view.findViewById(R.id.iv_mlxy_gkash_card).setOnClickListener(this);
             view.findViewById(R.id.iv_mlxy_gkash_card).setVisibility(VISIBLE);
         }
-        if (showCash){
+        if (showCash) {
             view.findViewById(R.id.iv_qianbi).setVisibility(VISIBLE);
-        }else {
+        } else {
             view.findViewById(R.id.iv_qianbi).setVisibility(GONE);
         }
         view.findViewById(R.id.iv_close).setOnClickListener(this);
@@ -96,11 +97,11 @@ public class ShoppingTrolleyDialogChoosePay extends FrameLayout implements View.
             ivNayax.setImageResource(R.drawable.icon_xinyongka_pay);
         }
 
-        llDiscountsCode=view.findViewById(R.id.ll_discounts_code);
-        if (Hawk.get(Name.PROMOTION_CODE,false)){
+        llDiscountsCode = view.findViewById(R.id.ll_discounts_code);
+        if (Hawk.get(Name.PROMOTION_CODE, false)) {
             Log.d(TAG, "ShoppingTrolleyDialogChoosePay:1 ");
             llDiscountsCode.setVisibility(VISIBLE);
-        }else {
+        } else {
             Log.d(TAG, "ShoppingTrolleyDialogChoosePay: 2");
             llDiscountsCode.setVisibility(GONE);
         }
@@ -233,7 +234,6 @@ public class ShoppingTrolleyDialogChoosePay extends FrameLayout implements View.
     }
 
 
-
     @Override
     public boolean dispatchTouchEvent(MotionEvent ev) {
         if (ev.getAction() == MotionEvent.ACTION_DOWN) {
@@ -244,6 +244,7 @@ public class ShoppingTrolleyDialogChoosePay extends FrameLayout implements View.
         }
         return super.dispatchTouchEvent(ev);
     }
+
     private View getCurrentFocus() {
         // 获取当前 Activity 的焦点视图
         if (getContext() instanceof Activity) {
@@ -251,6 +252,7 @@ public class ShoppingTrolleyDialogChoosePay extends FrameLayout implements View.
         }
         return null;
     }
+
     /**
      * 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时则不能隐藏
      *

+ 44 - 43
app/src/main/java/com/bgy/autosale/ui/consumer/IceCreamFragment.java

@@ -812,41 +812,45 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
         shoppingTrolleyDialogChoosePay.setListener(new DialogClickListener() {
             @Override
             public void onClickListener(int type) {
-                switch (type) {
-                    case 125:
-                        shoppingTrolleyDialogChoosePay.dismiss();
-                        break;
-                    case R.id.iv_qianbi:
-                        handlePaymentSelection(3, R.id.iv_qianbi, () -> showPayMixDialog());
-                        break;
-                    case R.id.iv_nayax:
-                        handlePaymentSelection(4, R.id.iv_nayax, () -> showNayaxCreditCard());
-                        break;
-                    case R.id.iv_w_mdb_xinyongka:
-                        handlePaymentSelection(4, R.id.iv_w_mdb_xinyongka, () -> showDialogWMDBCreditCard());
-                        break;
-                    case R.id.iv_qr_code:
-                        if (Hawk.get("PRICEBEAN") != null) {
-                            priceBeans = Hawk.get("PRICEBEAN");
-                        } else {
-                            dismissLoading();
-                            showToast("请重新设置价格");
-                            return;
-                        }
-                        Log.d(TAG, "onClickListener: 1");
-                        handlePaymentSelection(5, R.id.iv_qr_code, () -> carsPay(str()));//国内二码合一支付
-                        break;
-                    case R.id.btn_discounts_code:
-                        handlePaymentSelection(0, R.id.btn_discounts_code, null);
-                        break;
-                    case R.id.iv_mlxy_gkash:
-                        showLoading();
-                        handlePaymentSelection(5, R.id.iv_mlxy_gkash, () -> getGkashQrcode(String.valueOf(pri), currentDish.name));
-                        break;
-                    case R.id.iv_mlxy_gkash_card:
-                        showLoading();
-                        handlePaymentSelection(4, R.id.iv_mlxy_gkash_card, () -> getGkashCard(String.valueOf(pri), currentDish.name));
-                        break;
+                Log.d(TAG, "shoppingTrolleyDialogChoosePayonClickListener:1 " + type);
+                if (PreventSpeedClickUtil.isFastClick()) {
+                    Log.d(TAG, "shoppingTrolleyDialogChoosePayonClickListener:2 " + type);
+                    switch (type) {
+                        case 125:
+                            shoppingTrolleyDialogChoosePay.dismiss();
+                            break;
+                        case R.id.iv_qianbi:
+                            handlePaymentSelection(3, R.id.iv_qianbi, () -> showPayMixDialog());
+                            break;
+                        case R.id.iv_nayax:
+                            handlePaymentSelection(4, R.id.iv_nayax, () -> showNayaxCreditCard());
+                            break;
+                        case R.id.iv_w_mdb_xinyongka:
+                            handlePaymentSelection(4, R.id.iv_w_mdb_xinyongka, () -> showDialogWMDBCreditCard());
+                            break;
+                        case R.id.iv_qr_code:
+                            if (Hawk.get("PRICEBEAN") != null) {
+                                priceBeans = Hawk.get("PRICEBEAN");
+                            } else {
+                                dismissLoading();
+                                showToast("请重新设置价格");
+                                return;
+                            }
+                            Log.d(TAG, "onClickListener: 1");
+                            handlePaymentSelection(5, R.id.iv_qr_code, () -> carsPay(str()));//国内二码合一支付
+                            break;
+                        case R.id.btn_discounts_code:
+                            handlePaymentSelection(0, R.id.btn_discounts_code, null);
+                            break;
+                        case R.id.iv_mlxy_gkash:
+                            showLoading();
+                            handlePaymentSelection(5, R.id.iv_mlxy_gkash, () -> getGkashQrcode(String.valueOf(pri), currentDish.name));
+                            break;
+                        case R.id.iv_mlxy_gkash_card:
+                            showLoading();
+                            handlePaymentSelection(4, R.id.iv_mlxy_gkash_card, () -> getGkashCard(String.valueOf(pri), currentDish.name));
+                            break;
+                    }
                 }
             }
         });
@@ -868,12 +872,9 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                     ToastUtil.getInstance().showText(UiUtil.getStringRes(R.string.only_one_code));
                     return; // 直接返回,不继续执行
                 } else {
-                    if (PreventSpeedClickUtil.isFastClick()) {
-                        showLoading();
-                        if (shoppingNumber >= 0 && shoppingNumber < arrayCode.length) {
-                            getDiscountCodeOverseas(arrayCode[shoppingNumber], id);
-                        }
-                    } else {
+                    showLoading();
+                    if (shoppingNumber >= 0 && shoppingNumber < arrayCode.length) {
+                        getDiscountCodeOverseas(arrayCode[shoppingNumber], id);
                     }
                 }
             } else {
@@ -1097,7 +1098,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
             } else if (DishesBean.SPEC_CATEGORY_KERNEL.equals(specCategoryBean.code)) {
                 initSpecItems(kernelViews, specCategoryBean, false);
             }
-            Log.d(TAG, "initSpecView: "+specCategoryBean.specBeans);
+            Log.d(TAG, "initSpecView: " + specCategoryBean.specBeans);
         }
 
     }
@@ -2520,7 +2521,7 @@ public class IceCreamFragment extends BaseAutoExitFragment implements View.OnCli
                                     saveCoinOrder(productName, price, payType, sn, productNumber);
                                 }
                             }, 3000);
-                        } else if (Hawk.get(Name.AUTOUPLOADORDER, false)) {
+                        } else if (Hawk.get(Name.AUTOUPLOADORDER, true)) {
                             saveErrorOrder(productName, price, payType, sn, productNumber, getStackCompleteTime());
                         }
                     }

+ 18 - 3
app/src/main/java/com/bgy/autosale/ui/operator/OtherMaterielActivity.java

@@ -22,12 +22,14 @@ import com.hboxs.base_library.base.IView;
 import com.hboxs.base_library.constant.Global;
 import com.hboxs.base_library.constant.Heartbeat;
 import com.hboxs.base_library.constant.Name;
+import com.hboxs.base_library.event.ApiMessageEvent;
 import com.hboxs.base_library.http.NoPayOrderStringApi;
 import com.hboxs.base_library.http.observer.HttpResultNotActivityObserver;
 import com.hboxs.base_library.http.response.HttpResult;
 import com.hboxs.base_library.http.response.HttpResultHandler;
 import com.orhanobut.hawk.Hawk;
 
+import org.greenrobot.eventbus.EventBus;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -99,7 +101,7 @@ public class OtherMaterielActivity extends BaseScanGunActivity implements View.O
         if (materiel) {
             rbMaterialMonitorYes.setChecked(true);
         } else {
-            rbMaterialMonitorYes.setChecked(true);
+            rbMaterialMonitorNo.setChecked(true);
         }
     }
 
@@ -221,16 +223,28 @@ public class OtherMaterielActivity extends BaseScanGunActivity implements View.O
     private void isOpenMaterial(boolean isOpen) {
         Map<String, String> params = new HashMap<>();
         params.put("clientId",Heartbeat.deviceId);
-        params.put("isMaterialUse",isOpen==true?"0":"1");
+        String isMaterialUse;
+        if (isOpen){
+            isMaterialUse="1";
+        }else {
+            isMaterialUse="0";
+        }
+        params.put("isMaterialUse",isMaterialUse);
         addSubscriptionNew(NoPayOrderStringApi.api.updateMaterialStatus(params),String.class,
                 new HttpResultNotActivityObserver<String>(view, getApplicationContext()) {
                     @Override
                     public void onNext(String s) {
                         Log.d(TAG, "UpdateMaterialStatusApi onNext: "+s);
                         if ("success".equals(s)) {
-                            Hawk.put(Name.MATERIEL,true);
+                            Hawk.put(Name.MATERIEL,isOpen);
+                            if (isOpen){
+                                EventBus.getDefault().post(new ApiMessageEvent(Name.MATERIEL, "1"));
+                            }else {
+                                EventBus.getDefault().post(new ApiMessageEvent(Name.MATERIEL, "0"));
+                            }
                         }else {
                             Hawk.put(Name.MATERIEL,false);
+                            EventBus.getDefault().post(new ApiMessageEvent(Name.MATERIEL, "0"));
                         }
                     }
 
@@ -240,6 +254,7 @@ public class OtherMaterielActivity extends BaseScanGunActivity implements View.O
                         super.onError(t);
                         t.printStackTrace();
                         Hawk.put(Name.MATERIEL,false);
+                        EventBus.getDefault().post(new ApiMessageEvent(Name.MATERIEL, "0"));
                     }
                 });
     }

+ 1 - 1
app/src/main/java/com/bgy/autosale/ui/operator/SwitchSettingActivity.java

@@ -94,7 +94,7 @@ public class SwitchSettingActivity extends BaseScanGunActivity implements View.O
         rbAutoUploadYes = findViewById(R.id.rb_auto_upload_yes);
         rbAutoUploadNo = findViewById(R.id.rb_auto_upload_no);
 
-        Boolean alwaysIdle = Hawk.get(Name.AUTOUPLOADORDER, false);
+        Boolean alwaysIdle = Hawk.get(Name.AUTOUPLOADORDER, true);
         if (alwaysIdle) {
             rbAutoUploadYes.setChecked(true);
         } else {

+ 3 - 3
app/src/main/res/layout/dialog_pay_success.xml

@@ -180,7 +180,7 @@
     <TextView
         android:id="@+id/text_payment"
         android:layout_width="wrap_content"
-        android:maxWidth="80dp"
+        android:maxWidth="280dp"
         android:layout_height="wrap_content"
         android:layout_marginTop="@dimen/dp_8"
         android:gravity="center"
@@ -194,7 +194,7 @@
     <TextView
         android:id="@+id/text_make"
         android:layout_width="wrap_content"
-        android:maxWidth="80dp"
+        android:maxWidth="280dp"
         android:layout_height="wrap_content"
         android:layout_marginTop="@dimen/dp_8"
         android:gravity="center"
@@ -209,7 +209,7 @@
         android:id="@+id/text_finish"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:maxWidth="80dp"
+        android:maxWidth="280dp"
         android:layout_marginTop="@dimen/dp_8"
         android:gravity="center"
         android:text="@string/order_complete"

+ 1 - 1
app/src/main/res/layout/view_shop_cart.xml

@@ -123,7 +123,7 @@
             android:layout_height="0dp">
             <EditText
                 android:id="@+id/et_member_code"
-                android:hint="会员码此处输入"
+                android:hint="@string/member_code_input_here"
                 android:gravity="center"
                 android:selectAllOnFocus="true"
                 android:visibility="gone"

+ 1 - 1
app/src/main/res/values-de/strings.xml

@@ -61,7 +61,7 @@
     <string name="flavor_original">Vanilleeis</string>
     <string name="flavor_original_hw">Einfacher Softeis</string>
     <string name="flavor_multi">Eiscreme mit mehreren Geschmacksrichtungen</string>
-    <string name="flavor_sauce">Sirup +</string>
+    <string name="flavor_sauce">Saucen +</string>
     <string name="flavor_kernel">+ Toppings</string>
     <string name="shop_cart_add">zum Warenkorb \nhinzufügen</string>
     <string name="make_now">Machen</string>

+ 1 - 1
config.gradle

@@ -5,7 +5,7 @@ ext {
             "minSdkVersion"                : 21,
             "targetSdkVersion"             : 28,
             "versionCode"                  : 110,
-            "versionName"                  : "1.0.90-1",//版本号修改
+            "versionName"                  : "1.0.92",//版本号修改
 
             "androidSupport"               : "28.0.0",
             "constraint-layout"            : "1.1.3",

+ 4 - 0
lm-library/src/main/java/top/keepempty/sph/library/SphDataProcess.java

@@ -65,12 +65,16 @@ public class SphDataProcess {
     public SphDataProcess(int maxSize) {
         this.maxSize = maxSize;
         sphHandler = new SphHandler(this);
+        concurrentCom = new SphConcurrentCom();
     }
 
     /**
      * 串口写入数据
      */
     public void writeData() {
+        if (concurrentCom == null) {
+            concurrentCom = new SphConcurrentCom();
+        }
         if (concurrentCom.getCurrentCmdEntity() == null) {
             if (!concurrentCom.isCmdEmpty()&&concurrentCom.get()!=null) {
                 currentCommand = concurrentCom.get();