@@ -58,52 +58,31 @@ public class ConfigData { | |||
public void LoadSystem() | |||
{ | |||
ArrayList<BPA_SYSTEMSET> 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; | |||
} | |||
@@ -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; | |||
//值 | |||
@@ -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(); | |||
} | |||
} |
@@ -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<EditText> editTextLists=new ArrayList<>(); | |||
Map<String,Integer> material_map = new LinkedHashMap<>(); | |||
/** | |||
* 系统设置参数 | |||
*/ | |||
ArrayList<BPA_SYSTEMSET> 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<String> 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 <editTextLists.size();i++){ | |||
BPA_SYSTEMSET set=new BPA_SYSTEMSET(); | |||
set.type=i+1; | |||
set.value=editTextLists.get(i).getText().toString(); | |||
set.deviceID = ConfigName.getInstance().DeviceId; | |||
set.userID = ConfigName.getInstance().user.userID; | |||
QueryDB.AddSystemset(set); | |||
} | |||
BPA_SYSTEMSET set=new BPA_SYSTEMSET(); | |||
set.type=4; | |||
set.value=environment.getSelectedItem().toString(); | |||
set.deviceID = ConfigName.getInstance().DeviceId; | |||
set.userID = ConfigName.getInstance().user.userID; | |||
QueryDB.AddSystemset(set); | |||
ToastUtils.info("保存成功"); | |||
break; | |||
} | |||
} | |||
} |
@@ -102,6 +102,23 @@ public class fragment_gx extends LinearLayout { | |||
switch (model.datatype) | |||
{ | |||
case 0://数字 | |||
String text= edittext.getText().toString(); | |||
if(text.isEmpty()) | |||
{ | |||
text="0"; | |||
} | |||
int val=Integer.parseInt(text); | |||
if(model.IsWL) | |||
{ | |||
if(check.isChecked()) | |||
{ | |||
ResStu=String.valueOf(val); | |||
} | |||
}else | |||
{ | |||
ResStu=String.valueOf(val); | |||
} | |||
break; | |||
case 1://字符串 | |||
if(model.IsWL) | |||
{ | |||
@@ -0,0 +1,44 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<!-- Button 被按下时的样式 --> | |||
<item android:state_pressed="true"> | |||
<shape android:shape="oval"> | |||
<gradient | |||
android:startColor="#FF4081" | |||
android:endColor="#FF6699" | |||
android:type="sweep" | |||
android:angle="45" /> | |||
<padding | |||
android:left="10dp" | |||
android:top="10dp" | |||
android:right="10dp" | |||
android:bottom="10dp" /> | |||
<stroke | |||
android:width="2dp" | |||
android:color="#FF4081" /> | |||
</shape> | |||
</item> | |||
<!-- Button 正常状态下的样式 --> | |||
<item> | |||
<shape android:shape="oval"> | |||
<gradient | |||
android:startColor="#0088ff" | |||
android:endColor="#006bff" | |||
android:type="linear" | |||
android:angle="45" /> | |||
<padding | |||
android:left="5dp" | |||
android:top="5dp" | |||
android:right="10dp" | |||
android:bottom="10dp" /> | |||
<stroke | |||
android:width="2dp" | |||
android:color="#444444" /> | |||
</shape> | |||
</item> | |||
</selector> |
@@ -10,10 +10,110 @@ | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:background="@color/main_background"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="这里是系统设置的系统配置"/> | |||
<RelativeLayout | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<TableLayout | |||
android:layout_centerHorizontal="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<!-- Table1--> | |||
<TableRow | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_gravity="center" | |||
android:layout_margin="5dp"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="right" | |||
android:text="PLC连接地址:" /> | |||
<EditText | |||
android:id="@+id/edittext1" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入地址" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" /> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="right" | |||
android:text="PLC连接端口:" /> | |||
<EditText | |||
android:id="@+id/edittext2" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入端口" | |||
android:inputType="number" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" | |||
android:text="0"/> | |||
</TableRow> | |||
<!-- Table2--> | |||
<TableRow | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_gravity="left" | |||
android:layout_margin="5dp"> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="right" | |||
android:text="商家店铺号:" /> | |||
<EditText | |||
android:id="@+id/edittext3" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入商家店铺号" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" /> | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="right" | |||
android:text="链接环境:" /> | |||
<Spinner | |||
android:id="@+id/environment" | |||
style="@style/commonSpinnerStyle" | |||
android:layout_width="80dp" | |||
android:layout_height="24dp" | |||
android:layout_centerVertical="true" /> | |||
</TableRow> | |||
</TableLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="@dimen/dp_10" | |||
android:layout_marginLeft="@dimen/dp_40" | |||
android:layout_marginRight="@dimen/dp_40" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<Button | |||
android:id="@+id/StartButton" | |||
android:layout_width="match_parent" | |||
android:layout_height="45dp" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="保存参数" | |||
android:textColor="@color/white" | |||
android:textSize="18sp"/> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout> |