From e3059e0361a15e1fec9459cd8c6cf2dc6f4f60f6 Mon Sep 17 00:00:00 2001
From: liup <1454939542@qq.com>
Date: Tue, 21 May 2024 09:27:48 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B0=83=E8=AF=95=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/build.gradle | 10 +-
app/src/main/AndroidManifest.xml | 2 +-
.../bonait/bnframework/MainApplication.java | 58 ++
.../bnframework/Service/ModbusHelper.java | 27 +-
.../ViewModel/CustomView/item_gx.java | 10 +
.../FragmentViewModel/HomeDeviceFragment.java | 110 +---
.../db/util/GoodsProcessDetailDBUtil.java | 4 +-
.../db/util/SubAttributeGroupDBUtil.java | 8 +-
.../common/utils/DisplayManager.java | 12 +
.../ui/activity/DiyProcessActivity.java | 496 +++++++++++++++---
.../ui/activity/EditClassifyActivity.java | 8 +-
.../ui/adapter/ClassifyAdapter.java | 3 +
.../ui/adapter/DiyStepAdapter.java | 82 +++
.../ui/adapter/LocalGoodsAdapter.java | 2 +-
.../adapter/SelectAttributeListAdapter.java | 6 +-
.../bnframework/ui/dialog/AddGoodsDialog.java | 7 +-
.../ui/dialog/AttributeSelectDialog.java | 188 +++++++
.../ui/dialog/DeviceControlDialog.java | 270 ++++++++++
.../ui/dialog/EditGoodsDialog.java | 27 +-
.../ui/fragment/CloudGoodsFragment.java | 2 +-
.../ui/fragment/HomeDevicesFragment.java | 127 +++++
.../ui/fragment/HomeFoodsFragment.java | 12 +-
.../ui/fragment/LocalGoodsFragment.java | 5 +-
.../ui/viewmodel/HomeGoodsViewModel.java | 1 -
.../widget/FireView.java} | 30 +-
.../bnframework/ui/widget/NewToastUtil.java | 41 +-
.../ui/widget/ProcessValueView.java | 197 +++++++
.../ui/widget/SmoothLayoutManager.java | 55 ++
.../drawable/bg_round50_left_green_btn.xml | 21 +
.../drawable/bg_round50_right_green_btn.xml | 21 +
.../drawable/selector_select_step_text_bg.xml | 15 +
.../selector_select_step_text_color.xml | 6 +
.../selector_text_click_yellow_round15.xml | 17 +
.../main/res/layout/activity_edit_process.xml | 140 +++--
.../dialog/layout/dialog_attribute_select.xml | 81 +++
.../dialog/layout/dialog_delete_classify.xml | 13 +
.../dialog/layout/dialog_device_control.xml | 45 ++
.../layout/layout_add_goods_mainfood.xml | 6 +-
.../dialog/layout/layout_fire_control.xml | 140 +++++
.../dialog/layout/layout_food_control.xml | 143 +++++
.../dialog/layout/layout_silos_control.xml | 135 +++++
.../dialog/layout/layout_stir_control.xml | 180 +++++++
.../main/res/layout/fragment_home_device.xml | 11 -
.../main/res/layout/fragment_home_devices.xml | 36 ++
.../layout/item/layout/item_fire_control.xml | 68 +--
.../layout/item/layout/item_local_goods.xml | 10 +-
.../main/res/layout/item/layout/item_step.xml | 57 ++
.../layout/item/layout/view_process_value.xml | 52 ++
.../main/res/layout/view_device_control.xml | 85 +++
app/src/main/res/values/dimens.xml | 3 +-
app/src/main/res/values/styles.xml | 8 +-
51 files changed, 2752 insertions(+), 341 deletions(-)
create mode 100644 app/src/main/java/com/bonait/bnframework/ui/adapter/DiyStepAdapter.java
create mode 100644 app/src/main/java/com/bonait/bnframework/ui/dialog/AttributeSelectDialog.java
create mode 100644 app/src/main/java/com/bonait/bnframework/ui/dialog/DeviceControlDialog.java
create mode 100644 app/src/main/java/com/bonait/bnframework/ui/fragment/HomeDevicesFragment.java
rename app/src/main/java/com/bonait/bnframework/{ViewModel/CustomView/fire_control.java => ui/widget/FireView.java} (93%)
create mode 100644 app/src/main/java/com/bonait/bnframework/ui/widget/ProcessValueView.java
create mode 100644 app/src/main/java/com/bonait/bnframework/ui/widget/SmoothLayoutManager.java
create mode 100644 app/src/main/res/drawable/bg_round50_left_green_btn.xml
create mode 100644 app/src/main/res/drawable/bg_round50_right_green_btn.xml
create mode 100644 app/src/main/res/drawable/selector_select_step_text_bg.xml
create mode 100644 app/src/main/res/drawable/selector_select_step_text_color.xml
create mode 100644 app/src/main/res/drawable/selector_text_click_yellow_round15.xml
create mode 100644 app/src/main/res/layout/dialog/layout/dialog_attribute_select.xml
create mode 100644 app/src/main/res/layout/dialog/layout/dialog_device_control.xml
create mode 100644 app/src/main/res/layout/dialog/layout/layout_fire_control.xml
create mode 100644 app/src/main/res/layout/dialog/layout/layout_food_control.xml
create mode 100644 app/src/main/res/layout/dialog/layout/layout_silos_control.xml
create mode 100644 app/src/main/res/layout/dialog/layout/layout_stir_control.xml
create mode 100644 app/src/main/res/layout/fragment_home_devices.xml
create mode 100644 app/src/main/res/layout/item/layout/item_step.xml
create mode 100644 app/src/main/res/layout/item/layout/view_process_value.xml
create mode 100644 app/src/main/res/layout/view_device_control.xml
diff --git a/app/build.gradle b/app/build.gradle
index 9dccfee8..f501acfc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -152,9 +152,9 @@ dependencies {
//轮播图
implementation 'com.youth.banner:banner:1.4.10'
- //图片加载
- implementation 'com.github.bumptech.glide:glide:4.11.0'
- annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
+// //图片加载
+// implementation 'com.github.bumptech.glide:glide:4.11.0'
+// annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.yanzhenjie:permission:2.0.0-rc12'
@@ -198,4 +198,8 @@ dependencies {
//leak 内存泄漏检测
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-3'
+
+ //腾讯bugly
+ //sdk地址 https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=1.0.0
+ implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如4.0.3
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f3a3ebf6..609100f3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -37,9 +37,9 @@
android:name=".ViewModel.ActivityViewModel.DiyUpdate1Activity"
android:screenOrientation="portrait"
android:exported="false" />
+
res = ReadShort(statusModel.PlcAddress,1);
if(res.isSuccess){
- statusModel.Value.setValue(res.Content);
+// statusModel.Value.setValue(res.Content);
+ byte[] bytes = DataConvertLib.shorts2Bytes(res.Content);
+ if(bytes.length>=2){
+ deviceErrorCode = bytes[0] & 0xFF;
+ }
}
-
-
Thread.sleep(ConfigName.TEST?2000:200);
});
}
+
+ private int deviceErrorCode = 0;
+
+ public int getDeviceErrorCode() {
+ return deviceErrorCode;
+ }
+
+ public void setDeviceErrorCode(int deviceErrorCode) {
+ this.deviceErrorCode = deviceErrorCode;
+ }
+
+ public boolean getDisconnect(){
+ return isDisconnect;
+ }
}
diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java
index 94da7960..da86092f 100644
--- a/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java
+++ b/app/src/main/java/com/bonait/bnframework/ViewModel/CustomView/item_gx.java
@@ -9,4 +9,14 @@ public class item_gx {
public String data;
public boolean IsWL=false;
+
+ @Override
+ public String toString() {
+ return "item_gx{" +
+ "name='" + name + '\'' +
+ ", datatype=" + datatype +
+ ", data='" + data + '\'' +
+ ", IsWL=" + IsWL +
+ '}';
+ }
}
diff --git a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java
index 539ec96b..3bcac745 100644
--- a/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java
+++ b/app/src/main/java/com/bonait/bnframework/ViewModel/FragmentViewModel/HomeDeviceFragment.java
@@ -1,8 +1,5 @@
package com.bonait.bnframework.ViewModel.FragmentViewModel;
-import static com.bonait.bnframework.MainApplication.getContext;
-import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
-
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Bundle;
@@ -20,22 +17,15 @@ import android.widget.ArrayAdapter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.core.content.ContextCompat;
import com.apkfuns.logutils.LogUtils;
-import com.bonait.bnframework.HBL.DataUtil.DataConvertLib;
import com.bonait.bnframework.HBL.DataUtil.ErrorCodeManager;
-import com.bonait.bnframework.HBL.DataUtil.NotifyPropVar;
import com.bonait.bnframework.HBL.Interface.IRunT;
-import com.bonait.bnframework.HBL.Result.OperateResultT;
import com.bonait.bnframework.HBL.Thread.ThreadManager;
import com.bonait.bnframework.Model.ErrorCodeBean;
import com.bonait.bnframework.R;
-import com.bonait.bnframework.Service.ControlAdress;
import com.bonait.bnframework.Service.ModbusHelper;
-import com.bonait.bnframework.Service.PLCModel;
import com.bonait.bnframework.common.base.BaseFragment;
-import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.DisplayManager;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.databinding.FragmentHomeDeviceBinding;
@@ -58,8 +48,7 @@ public class HomeDeviceFragment extends BaseFragment {
private List mainFoodList;
private int seasoningPos = -1;
private int mainFoodPos = -1;
- private static final int MSG_UPDATE_STATUS = 1;
- private static final int MSG_UPDATE_ERROR_CODE = 2;
+ private static final int MSG_FRESH_DEVICE = 1000;
@@ -69,18 +58,17 @@ public class HomeDeviceFragment extends BaseFragment {
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
switch (msg.what){
- case MSG_UPDATE_STATUS:
- boolean status = (boolean) msg.obj;
- changeTextDeviceStatus(2,status?"掉线":"在线");
-
- break;
- case MSG_UPDATE_ERROR_CODE:
- int code = (int) msg.obj;
+ case MSG_FRESH_DEVICE:
+ if(hasMessages(MSG_FRESH_DEVICE)){
+ removeMessages(MSG_FRESH_DEVICE);
+ }
+ sendEmptyMessageDelayed(MSG_FRESH_DEVICE,500);
for(ErrorCodeBean bean : ErrorCodeManager.getInstance().getDataBeans()){
- if(bean.getCode() == code){
+ if(bean.getCode() == ModbusHelper.get().getDeviceErrorCode()){
changeTextDeviceStatus(1,bean.getName()+" "+bean.getDescription());
}
}
+ changeTextDeviceStatus(2,ModbusHelper.get().getConnected()?"在线":"掉线");
break;
}
}
@@ -121,87 +109,13 @@ public class HomeDeviceFragment extends BaseFragment {
mainFoodList.add("主料仓4(投料4)");
mainFoodList.add("主料仓5(投料5)");
mainFoodList.add("主料仓6(投料6)");
- handler.post(() -> {
- try {
- PLCModel statusModel = ModbusHelper.get().controlAddress.get(ControlAdress.状态读取);
-// ModbusHelper.get().WriteBool(ModbusHelper.get().getPLC(ControlAdress.状态读取启动).PlcAddress,true);
- OperateResultT res = ModbusHelper.get().ReadShort(statusModel.PlcAddress,1);
- byte[] bytes = DataConvertLib.shorts2Bytes(res.Content);
- if(bytes.length>=2){
- progressFire = bytes[1] & 0xFF;
- }
- if(!release){
- viewBinding.fireProgress.setValue(progressFire,true);
- }
+ if(handler.hasMessages(MSG_FRESH_DEVICE)){
+ handler.removeMessages(MSG_FRESH_DEVICE);
+ }
+ handler.sendEmptyMessageDelayed(MSG_FRESH_DEVICE,500);
- PLCModel statusModel2 = ModbusHelper.get().controlAddress.get(ControlAdress.搅拌档位);
- OperateResultT res2 = ModbusHelper.get().ReadShort(statusModel2.PlcAddress,1);
- byte[] bytes2 = DataConvertLib.shorts2Bytes(res2.Content);
- progressStir = bytes2[0] & 0xFF;
- if(!release){
- viewBinding.stirProgress.setValue(progressStir,true);
- }
- LogUtils.d("HomeDeviceFragment initData progressFire="+progressFire +" progressStir="+progressStir);
- }catch (Exception e){
- LogUtils.d(e.getMessage()+"");
- }
- });
- NotifyPropVar notifyPropVar1 = (NotifyPropVar)ModbusHelper.get().getPLC(ControlAdress.状态读取).Value;
- notify1 = new IRunT() {
- @Override
- public void Run(short[] shorts) {
- byte[] bytes = DataConvertLib.shorts2Bytes(shorts);
- String result = DataConvertLib.bytesToString(bytes);
- if(ConfigName.LOG_TEST){
- LogUtils.d("HomeDeviceFragment result="+result +" bytes.length="+bytes.length);
- }
- if(handler!=null){
- if(ErrorCodeManager.getInstance().getDataBeans()!=null){
- int code = 0;
- if(bytes.length>=2){
- code = bytes[0] & 0xFF;
- if(ConfigName.LOG_TEST){
- LogUtils.d("HomeDeviceFragment code="+code );
- }
- }
- Message message = new Message();
- message.what = MSG_UPDATE_ERROR_CODE;
- message.obj = code;
- if(handler.hasMessages(MSG_UPDATE_ERROR_CODE)){
- handler.removeMessages(MSG_UPDATE_ERROR_CODE);
- }
- handler.sendMessageDelayed(message,500);
- }
- }
- }
- };
- if(notifyPropVar1!=null){
- notifyPropVar1.Register(HomeDeviceFragment.class.getSimpleName(), notify1);
- }
-
- NotifyPropVar notifyPropVar = (NotifyPropVar)ModbusHelper.get().getPLC(ControlAdress.掉线标志).Value;
- notify = new IRunT() {
- @Override
- public void Run(Boolean status) {
- if(ConfigName.LOG_TEST){
- LogUtils.d("HomeDeviceFragment status="+status );
- }
- if(handler!=null){
- Message message = new Message();
- message.what = 1;
- message.obj = status;
- if(handler.hasMessages(MSG_UPDATE_STATUS)){
- handler.removeMessages(MSG_UPDATE_STATUS);
- }
- handler.sendMessageDelayed(message,500);
- }
- }
- };
- if(notifyPropVar!=null){
- notifyPropVar.Register(HomeDeviceFragment.class.getSimpleName(), notify);
- }
}
private void initView(){
diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java
index a88d24ab..0a978243 100644
--- a/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java
+++ b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsProcessDetailDBUtil.java
@@ -74,14 +74,14 @@ public class GoodsProcessDetailDBUtil {
public static ArrayList getByGroupId(String groupId) {
String orderby = QueryDB.Desc_Sort_Up + ',' + QueryDB.Desc_Time_Up;
String where = "goodsSubAttributeGroupId=?";
- String[] args = new String[]{"0", groupId};
+ String[] args = new String[]{groupId};
ArrayList data = new ArrayList<>();
ArrayList