diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9fb80475..e3f47563 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -145,7 +145,9 @@ tools:ignore="Instantiatable" /> + android:exported="false" + android:windowSoftInputMode="stateHidden|stateAlwaysHidden" + /> @@ -178,6 +180,7 @@ + diff --git a/app/src/main/java/com/bonait/bnframework/common/cookie/CookieHelper.java b/app/src/main/java/com/bonait/bnframework/common/cookie/CookieHelper.java index ad3012d5..920d3c67 100644 --- a/app/src/main/java/com/bonait/bnframework/common/cookie/CookieHelper.java +++ b/app/src/main/java/com/bonait/bnframework/common/cookie/CookieHelper.java @@ -47,4 +47,38 @@ public class CookieHelper { .show(); } } + + public static void Show(Activity activity, String title, String message,int showTime) { + if (Mode == 1) { + new CookieBar.Builder(activity) + .setBackgroundColor(R.color.app_color_blue) + .setActionColor(android.R.color.white) + .setTitleColor(R.color.white) + .setTitle(title) + .setMessage(message) + .setDuration(showTime) + .setActionWithIcon(R.mipmap.ic_action_close, new OnActionClickListener() { + @Override + public void onClick() { + + } + }) + .show(); + } else { + new CookieBar.Builder(activity) + .setTitle(title) + .setMessage(message) + .setDuration(showTime) + .setBackgroundColor(R.color.app_color_blue) + .setActionColor(android.R.color.white) + .setTitleColor(R.color.white) + .setAction("已读确认关闭", new OnActionClickListener() { + @Override + public void onClick() { + + } + }) + .show(); + } + } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java index f382e6ff..da44943d 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java @@ -6,8 +6,15 @@ import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager; import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; import android.util.Log; +import android.view.KeyEvent; import android.view.MenuItem; +import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; import android.widget.RelativeLayout; import com.bonait.bnframework.R; @@ -51,6 +58,8 @@ public class BottomNavigationMainActivity extends BaseActivity{ @BindView(R.id.viewpager) QMUIViewPager viewPager; + @BindView(R.id.Test_res) + EditText shaoma_Text; @Override protected void onCreate(Bundle savedInstanceState) { @@ -69,9 +78,56 @@ public class BottomNavigationMainActivity extends BaseActivity{ initFragment(); Init(); + shaoma_Text.requestFocus(); + shaoma_Text.setOnFocusChangeListener(new View.OnFocusChangeListener() { + @Override + public void onFocusChange(View v, boolean hasFocus) { + if (hasFocus) { + } else { + shaoma_Text.clearFocus(); + shaoma_Text.requestFocus(); + } + } + }); + shaoma_Text.setOnKeyListener(new View.OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) { + if (shaoma_Text.getText() != null && shaoma_Text.getText().toString() != "") { + String msg = shaoma_Text.getText().toString(); + msg = msg.replace("\\n", ""); + if (fragmentList.size()>2){ + MakeGoodFragment makeGoodFragment=(MakeGoodFragment) fragmentList.get(2); + makeGoodFragment.RecipeRun(msg); + } + /*RecipeRun(msg);*/ + } + shaoma_Text.setText(""); + + } + return false; + } + }); + InputMethodManager im = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); + shaoma_Text.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + @Override + public void afterTextChanged(Editable s) { + im.hideSoftInputFromWindow(shaoma_Text.getWindowToken(), 0); + } + }); + } + @Override protected void onDestroy() { //关闭PLC连接 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java index 0de71e8a..89eb00d0 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java @@ -1,5 +1,6 @@ package com.bonait.bnframework.modules.home.fragment; +import static android.content.Context.INPUT_METHOD_SERVICE; import static com.bonait.bnframework.MainApplication.getContext; import androidx.annotation.NonNull; @@ -16,11 +17,21 @@ import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.os.ResultReceiver; +import android.text.Editable; +import android.text.InputType; +import android.text.TextWatcher; +import android.text.method.KeyListener; import android.util.Log; import android.view.Gravity; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; import android.widget.Button; +import android.widget.EditText; import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.TextView; @@ -85,6 +96,9 @@ import com.qmuiteam.qmui.widget.QMUIViewPager; import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; +import org.w3c.dom.Text; + +import java.lang.reflect.Method; import java.security.PublicKey; import java.util.ArrayList; import java.util.Arrays; @@ -94,6 +108,7 @@ import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; +import io.netty.util.internal.StringUtil; /** * @@ -102,10 +117,7 @@ public class MakeGoodFragment extends BaseFragment { private String TAG="主页面"; - public void InfoView(String shaoma){ - shaoma_view.setVisibility(3); - shaoma_Text.setText(shaoma); - } + private QMUIViewPager viewPager; @BindView(R.id.topbar) QMUITopBarLayout mTopBar;//顶部标题 @@ -161,7 +173,7 @@ public class MakeGoodFragment extends BaseFragment { * 获取扫码内容 */ @BindView(R.id.res_text) - TextView shaoma_Text; + EditText shaoma_Text; /** * 扫码界面展示 @@ -194,7 +206,7 @@ public class MakeGoodFragment extends BaseFragment { Run(); - ShaomaTest.Getinstance().Open(activity,this.context); + /*ShaomaTest.Getinstance().Open(activity,this.context);*/ /* SerialManage.GetInstance().init(new SerialInter() { @Override public void connectMsg(String path, boolean isSucc) { @@ -490,9 +502,9 @@ public class MakeGoodFragment extends BaseFragment { } break; case R.id.yes: - shaoma_view.setVisibility(View.GONE); + shaoma_view.setVisibility(View.INVISIBLE); case R.id.no: - shaoma_view.setVisibility(View.GONE); + shaoma_view.setVisibility(View.INVISIBLE); } } @@ -520,6 +532,102 @@ public class MakeGoodFragment extends BaseFragment { }; int time=0; + + + + public void RecipeRun(String msg) + { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + if ((msg != null) && (((String) msg).length() > 2) && ((String) msg).contains("|")) { + //拿到扫码数据 + //例如 ORD001|P0003|A001,M002,T001|2 + // OR001|A001|2,22|1 + + String[] res = ((String) msg).split("[|]"); + if (res.length >= 4) { + String orderid = res[0];//ORD001 + String goodid = res[1];//P0003 商品id + String ggid = res[2];//A001,M002,T001 配方ids + + String ggids = "";//规格id集合 + String names = ""; + + if (QueryDB.GetOrderthirdPartyIDIs(orderid)) { + message = "已有订单,重复扫码!"; + mHandler.sendEmptyMessage(1); + return; + } + int num = 1; + try { + num = Integer.parseInt(res[3]); + for (String item : ggid.split("[,]")) { + for (ResGoodProperty k : DataBus.getInstance().bpa_goodproperties) { + if (k.child != null && k.child.size() > 0) { + for (ResGoodProperty chd : k.child) { + if (chd.foreignKeyRe != null && !chd.foreignKeyRe.isEmpty() && chd.foreignKeyRe.equals(item)) { + ggids += chd.id + ","; + names += "/" + chd.name; + } + } + } + + } + } + + if (!ggids.isEmpty()) { + ggids = ggids.substring(0, ggids.length() - 1); + } + } catch (Exception ex) { + } + + BPA_GOODS good = QueryDB.GetGoodsforeignKeyId(goodid); + if (good == null) { + message = "没有查询到该商品!"; + mHandler.sendEmptyMessage(1); + } else { + BPA_GOODSRECIPENAME goodsrecipename = QueryDB.GetGoodsRecipeNameDesignId(ggids, good.id); + if (goodsrecipename != null) { + BPA_ORDER order = new BPA_ORDER(); + order.thirdPartyID = orderid; + order.status = 0; + order.deviceID = ConfigName.getInstance().DeviceId; + order.userID = ConfigName.getInstance().user.userID; + QueryDB.AddOrder(order); + + for (int mm = 0; mm < num; mm++) { + BPA_SUBORDER suborder = new BPA_SUBORDER(); + suborder.deviceID = ConfigName.getInstance().DeviceId; + suborder.userID = ConfigName.getInstance().user.userID; + suborder.orderID = order.id; + suborder.goodsID = good.id; + suborder.recipeID = goodsrecipename.id; + suborder.number = 1; + suborder.status = 0; + suborder.exp = names; + QueryDB.AddSubOrder(suborder); + DataBus.getInstance().AddGoodsMake(suborder); + } + message = "加入订单队列成功!"; + mHandler.sendEmptyMessage(2); + } else { + message = "没有查询到该商品配方信息!"; + mHandler.sendEmptyMessage(1); + } + } + + } else { + message = "没有查询到该商品!"; + mHandler.sendEmptyMessage(1); + } + } else { + message = "服务器异常,请稍后重试!"; + mHandler.sendEmptyMessage(1); + } + } + }); + } /** * 实时显示线程 */ diff --git a/app/src/main/res/layout/activity_bottom_navigation_main.xml b/app/src/main/res/layout/activity_bottom_navigation_main.xml index 24f40d60..1ab1a7cc 100644 --- a/app/src/main/res/layout/activity_bottom_navigation_main.xml +++ b/app/src/main/res/layout/activity_bottom_navigation_main.xml @@ -11,6 +11,7 @@ + + + + + + + diff --git a/app/src/main/res/layout/fragment_make_good.xml b/app/src/main/res/layout/fragment_make_good.xml index 07bd7e00..81461c25 100644 --- a/app/src/main/res/layout/fragment_make_good.xml +++ b/app/src/main/res/layout/fragment_make_good.xml @@ -6,6 +6,7 @@ android:layout_height="match_parent" android:background="@color/app_color_blue"> + + android:clickable="true"/> + - @@ -281,4 +284,5 @@ + \ No newline at end of file