From 3090cc6a82f2ace6ab9dd235f26f0c937478758b Mon Sep 17 00:00:00 2001 From: fyf Date: Tue, 4 Jul 2023 17:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=B3=BB=E7=BB=9F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bnframework/business/ConfigData.java | 69 ++--------- .../common/db/mode/BPA_SYSTEMSET.java | 20 +--- .../activity/BottomNavigation2Activity.java | 8 ++ .../fragment/SystemSystemsetFragment.java | 98 ++++++++++++++++ .../home/fragment/mode/fragment_gx.java | 17 +++ app/src/main/res/drawable/bt_circular.xml | 44 +++++++ .../res/layout/fragment_system_systemset.xml | 108 +++++++++++++++++- 7 files changed, 287 insertions(+), 77 deletions(-) create mode 100644 app/src/main/res/drawable/bt_circular.xml diff --git a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java index 5169cb66..aa22bba3 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ConfigData.java +++ b/app/src/main/java/com/bonait/bnframework/business/ConfigData.java @@ -58,52 +58,31 @@ public class ConfigData { public void LoadSystem() { ArrayList bpa_systemsets= QueryDB.GetSystemsetALL(); - for (int i = 0; i <12;i++){ +// for(BPA_SYSTEMSET item:bpa_systemsets) +// { +// QueryDB.DeleteSystemset(item.id); +// } + for (int i = 0; i <4;i++){ int ty=i+1; BPA_SYSTEMSET set=new BPA_SYSTEMSET(); set.type=ty; switch (ty) { case 1: - set.value=String.valueOf(ConfigName.getInstance().OrderPushTime); + set.value=ConfigName.getInstance().Address; break; case 2: - set.value=String.valueOf(ConfigName.getInstance().SilosValuePushTime); + set.value=String.valueOf(ConfigName.getInstance().Post); break; case 3: - set.value=String.valueOf(ConfigName.getInstance().OtherValuePushTime); - break; - case 4: - set.value=String.valueOf(ConfigName.getInstance().PipeDrainCycleTime); - break; - case 5: - set.value=String.valueOf(ConfigName.getInstance().OrderTimeout); - break; - case 6: - set.value=String.valueOf(ConfigName.getInstance().SiloFeedThreshold); - break; - case 7: - set.value=String.valueOf(ConfigName.getInstance().SiloAlarmThreshold); - break; - case 8: - set.value=String.valueOf(ConfigName.getInstance().AICleanTime); - break; - case 9: set.value=ConfigName.getInstance().AutKey; break; - case 10: - set.value=ConfigName.getInstance().Address; - break; - case 11: - set.value=String.valueOf(ConfigName.getInstance().Post); - break; - case 12: + case 4: set.value=ConfigName.getInstance().Environment; break; } set.deviceID = ConfigName.getInstance().DeviceId; set.userID = ConfigName.getInstance().user.userID; - BPA_SYSTEMSET find=null; for (BPA_SYSTEMSET item:bpa_systemsets) { @@ -118,45 +97,21 @@ public class ConfigData { QueryDB.AddSystemset(set); } } - + bpa_systemsets= QueryDB.GetSystemsetALL(); for (BPA_SYSTEMSET item:bpa_systemsets) { switch (item.type) { case 1: - ConfigName.getInstance().OrderPushTime=Integer.parseInt(item.value); + ConfigName.getInstance().Address=item.value; break; case 2: - ConfigName.getInstance().SilosValuePushTime=Integer.parseInt(item.value); + ConfigName.getInstance().Post=Integer.parseInt(item.value); break; case 3: - ConfigName.getInstance().OtherValuePushTime=Integer.parseInt(item.value); - break; - case 4: - ConfigName.getInstance().PipeDrainCycleTime=Integer.parseInt(item.value); - break; - case 5: - ConfigName.getInstance().OrderTimeout=Integer.parseInt(item.value); - break; - case 6: - ConfigName.getInstance().SiloFeedThreshold=Integer.parseInt(item.value); - break; - case 7: - ConfigName.getInstance().SiloAlarmThreshold=Integer.parseInt(item.value); - break; - case 8: - ConfigName.getInstance().AICleanTime=Integer.parseInt(item.value); - break; - case 9: ConfigName.getInstance().AutKey=item.value; break; - case 10: - ConfigName.getInstance().Address=item.value; - break; - case 11: - ConfigName.getInstance().Post=Integer.parseInt(item.value); - break; - case 12: + case 4: ConfigName.getInstance().Environment=item.value; break; } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SYSTEMSET.java b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SYSTEMSET.java index 5d724ef4..d1a32ec3 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SYSTEMSET.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SYSTEMSET.java @@ -7,22 +7,10 @@ package com.bonait.bnframework.common.db.mode; public class BPA_SYSTEMSET extends ModeBase{ /** * 类型: - * 1 订单上报周期 - * 2 料仓余量上报周期 - * 3 其他传感器上报周期 - * 4 管道排空周期 - * 5 订单未制作超时规则 - * 6 料仓补料阈值 - * 7 料仓告警阈值 - * 8 自动清洗时间 - * 9 设备id 店铺Autkey - * 10 PLC地址 - * 11 PLC端口 - * 12 MQTT 用户名 - * 13 MQTT 密码 - * 14 mqtt ip - * 15 mqtt 端口 - * 16 mqtt 主题 + * 1 设备id 店铺Autkey + * 2 PLC地址 + * 3 PLC端口 + * 4 链接环境 */ public int type; //值 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java index 73b9741b..6fc2b0ce 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java @@ -2,6 +2,8 @@ package com.bonait.bnframework.modules.home.activity; import android.os.Bundle; import androidx.annotation.NonNull; + +import com.bonait.bnframework.business.ConfigData; import com.google.android.material.bottomnavigation.BottomNavigationView; import androidx.viewpager.widget.ViewPager; import android.view.KeyEvent; @@ -46,6 +48,7 @@ public class BottomNavigation2Activity extends BaseActivity { // 设置viewPager缓存多少个fragment viewPager.setOffscreenPageLimit(3); bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); + Init(); } /** @@ -138,4 +141,9 @@ public class BottomNavigation2Activity extends BaseActivity { } return super.onKeyDown(keyCode, event); } + + public void Init() + { + ConfigData.getInstance().ToggleEnvironment(); + } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSystemsetFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSystemsetFragment.java index 26c89952..e5e67d39 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSystemsetFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSystemsetFragment.java @@ -7,16 +7,44 @@ import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.Spinner; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SYSTEMSET; +import com.bonait.bnframework.common.utils.ToastUtils; import com.orhanobut.logger.Logger; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import butterknife.BindView; import butterknife.ButterKnife; +import butterknife.OnClick; public class SystemSystemsetFragment extends BaseFragment { + @BindView(R.id.edittext1) + EditText edittext1; + @BindView(R.id.edittext2) + EditText edittext2; + @BindView(R.id.edittext3) + EditText edittext3; + @BindView(R.id.environment) + Spinner environment; + ArrayList editTextLists=new ArrayList<>(); + Map material_map = new LinkedHashMap<>(); + /** + * 系统设置参数 + */ + ArrayList bpa_systemsets=new ArrayList<>(); private Context context; @Override protected View onCreateView() { @@ -30,6 +58,7 @@ public class SystemSystemsetFragment extends BaseFragment { super.onViewCreated(view, savedInstanceState); Logger.d("我的fragment创建"); context = getContext(); + initData(); } @Override @@ -51,4 +80,73 @@ public class SystemSystemsetFragment extends BaseFragment { protected boolean canDragBack() { return false; } + + private void initData() + { + editTextLists.add(edittext1); + editTextLists.add(edittext2); + editTextLists.add(edittext3); + + material_map.put("开发环境",0); + material_map.put("测试环境",1); + material_map.put("正式环境",2); + ArrayAdapter adapter = new ArrayAdapter<>(context, R.layout.spinner_text_item, new ArrayList<>(material_map.keySet())); + adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + environment.setAdapter(adapter); + + bpa_systemsets= QueryDB.GetSystemsetALL(); + for (BPA_SYSTEMSET item:bpa_systemsets) { + switch (item.type) { + case 1: + ConfigName.getInstance().Address=item.value; + edittext1.setText(item.value); + break; + case 2: + ConfigName.getInstance().Post=Integer.parseInt(item.value); + edittext2.setText(item.value); + break; + case 3: + ConfigName.getInstance().AutKey=item.value; + edittext3.setText(item.value); + break; + case 4: + ConfigName.getInstance().Environment=item.value; + environment.setSelection(material_map.get(item.value)); + break; + } + } + } + + @OnClick({R.id.StartButton}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.StartButton://保存按钮 + ConfigName.getInstance().AutKey=edittext1.getText().toString(); + ConfigName.getInstance().Address=edittext2.getText().toString(); + ConfigName.getInstance().Post=Integer.parseInt(edittext3.getText().toString()); + ConfigName.getInstance().Environment=environment.getSelectedItem().toString(); + for (BPA_SYSTEMSET item:bpa_systemsets) + { + QueryDB.DeleteSystemset(item.id); + } + for (int i = 0; i + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_system_systemset.xml b/app/src/main/res/layout/fragment_system_systemset.xml index 83f6d9e1..c0ec4b66 100644 --- a/app/src/main/res/layout/fragment_system_systemset.xml +++ b/app/src/main/res/layout/fragment_system_systemset.xml @@ -10,10 +10,110 @@ android:layout_height="match_parent" android:orientation="vertical" android:background="@color/main_background"> - + + + + + + + + + + + + + + + + + + + + + + + +