diff --git a/.idea/misc.xml b/.idea/misc.xml index 3895d14..bcf7264 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/app/src/main/java/com/example/bpa/app/ICSApp.java b/app/src/main/java/com/example/bpa/app/ICSApp.java index 79facc8..ef49dcf 100644 --- a/app/src/main/java/com/example/bpa/app/ICSApp.java +++ b/app/src/main/java/com/example/bpa/app/ICSApp.java @@ -54,12 +54,14 @@ public class ICSApp extends Application { //1.设置程序active,初始化Main函数进程 ConfigName.getInstance().dishesCon = this; ToastUtil.init(this); - Main.getInstance(); + //2.初始化SD卡,数据库DB SdCart.getInstance().initSD(); BusinessServer.get().Start(); //3.初始化数据 InitDBdata(); + //4.初始化Main + Main.getInstance(); } /** diff --git a/app/src/main/java/com/example/bpa/app/Main.java b/app/src/main/java/com/example/bpa/app/Main.java index e649561..f636d88 100644 --- a/app/src/main/java/com/example/bpa/app/Main.java +++ b/app/src/main/java/com/example/bpa/app/Main.java @@ -2,10 +2,14 @@ package com.example.bpa.app; import com.example.bpa.config.ConfigName; +import com.example.bpa.db.QueryDB; +import com.example.bpa.db.mode.BPA_SYSTEMSET; import com.example.bpa.db.mode.BPA_USER; import com.example.bpa.helper.ConfigUtil; import com.example.bpa.helper.T; +import java.util.ArrayList; + /** * 主函数进程 * 主要进行配置文件-系统类 @@ -32,22 +36,121 @@ public class Main { * 初始化 */ public void Init() { - //1.加载配置 + //1.加载系统设置 + LoadSystem(); + //2.加载配置 + LoadingDPPZ(); LoadingPZ(); - //2.初始化PLC -// PLC.getInstance().InitMobus(); //3.初始化业务 //4.初始化日志上报adad } + /** + * 加载系统配置 + */ + public void LoadSystem() + { + ArrayList bpa_systemsets= QueryDB.GetSystemsetALL(); + if (bpa_systemsets.size()<=0) + { + for (int i = 0; i <10;i++){ + BPA_SYSTEMSET set=new BPA_SYSTEMSET(); + set.type=i+1; + switch (i+1) + { + case 1: + set.value=String.valueOf(ConfigName.getInstance().OrderPushTime); + break; + case 2: + set.value=String.valueOf(ConfigName.getInstance().SilosValuePushTime); + 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: + break; + } + set.deviceID = ConfigName.getInstance().DeviceId; + set.userID = ConfigName.getInstance().user.userID; + QueryDB.AddSystemset(set); + } + }else + { + for (BPA_SYSTEMSET item:bpa_systemsets) + { + switch (item.type) + { + case 1: + ConfigName.getInstance().OrderPushTime=Integer.parseInt(item.value); + break; + case 2: + ConfigName.getInstance().SilosValuePushTime=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: + break; + case 11: + break; + + } + } + } + + } + /** + * 加载店铺配置 + */ + public void LoadingDPPZ() { + //ConfigName.getInstance().AutKey + ConfigName.getInstance().Shop_Name="黑菠萝奶茶机"; + ConfigName.getInstance().DeviceId="20020415-test"; + } /** * 加载配置 */ public void LoadingPZ() { //1.店铺配置 - ConfigName.getInstance().Shop_Name = ConfigUtil.read(ConfigName.getInstance().dishesCon, "Shop_Name", ConfigName.getInstance().Shop_Name); - ConfigName.getInstance().AutKey = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutKey", ConfigName.getInstance().AutKey); +// ConfigName.getInstance().Shop_Name = ConfigUtil.read(ConfigName.getInstance().dishesCon, "Shop_Name", ConfigName.getInstance().Shop_Name); +// ConfigName.getInstance().AutKey = ConfigUtil.read(ConfigName.getInstance().dishesCon, "AutKey", ConfigName.getInstance().AutKey); //2.用户名称 ConfigName.getInstance().user.account = ConfigUtil.read(ConfigName.getInstance().dishesCon, "username", ConfigName.getInstance().user.account); ConfigName.getInstance().user.pass = ConfigUtil.read(ConfigName.getInstance().dishesCon, "password", ConfigName.getInstance().user.pass); @@ -59,8 +162,8 @@ public class Main { public void SavePZ() { //1.店铺配置 - ConfigUtil.write(ConfigName.getInstance().dishesCon,"Shop_Name", ConfigName.getInstance().Shop_Name); - ConfigUtil.write(ConfigName.getInstance().dishesCon,"AutKey", ConfigName.getInstance().AutKey); +// ConfigUtil.write(ConfigName.getInstance().dishesCon,"Shop_Name", ConfigName.getInstance().Shop_Name); +// ConfigUtil.write(ConfigName.getInstance().dishesCon,"AutKey", ConfigName.getInstance().AutKey); //2.用户信息 ConfigUtil.write(ConfigName.getInstance().dishesCon,"username", ConfigName.getInstance().user.account); ConfigUtil.write(ConfigName.getInstance().dishesCon,"password", ConfigName.getInstance().user.pass); diff --git a/app/src/main/java/com/example/bpa/db/QueryDB.java b/app/src/main/java/com/example/bpa/db/QueryDB.java index f92e7b9..6f3744c 100644 --- a/app/src/main/java/com/example/bpa/db/QueryDB.java +++ b/app/src/main/java/com/example/bpa/db/QueryDB.java @@ -1140,11 +1140,10 @@ public class QueryDB { * 删除系统设置 * add fengyoufu 20230413 * - * @param data * @return 是否成功 */ - public static boolean DeleteSystemset(BPA_SYSTEMSET data) { - return Delete(BPA_SYSTEMSET.class, data.id); + public static boolean DeleteSystemset(String id) { + return Delete(BPA_SYSTEMSET.class, id); } /** diff --git a/app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java b/app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java index bd32ba0..7c25220 100644 --- a/app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java +++ b/app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java @@ -22,6 +22,7 @@ import com.example.bpa.db.QueryDB; import com.example.bpa.db.mode.BPA_LOG; import com.example.bpa.helper.MessageLog; import com.example.bpa.view.fragment.setting.Fragment_lcparameter; +import com.example.bpa.view.fragment.setting.systemparameter; /** * 系统设置界面 @@ -35,12 +36,13 @@ public class SystemSetFragment extends Fragment implements View.OnClickListener private Button btn_lc_set; private Fragment lcparameter; + private Fragment Systemparameter; private Fragment SelectFragment; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - view = inflater.inflate(R.layout.fragment_system_set, container,false); + view = inflater.inflate(R.layout.fragment_system_set, container, false); Init(); initEvent(); return view; @@ -49,6 +51,7 @@ public class SystemSetFragment extends Fragment implements View.OnClickListener private void Init() { lcparameter = new Fragment_lcparameter(); + Systemparameter = new systemparameter(); btn_system_set = view.findViewById(R.id.stparameter); btn_lc_set = view.findViewById(R.id.lcparameter); MessageLog.MsgNotify = new IMessageLogNotify() { @@ -59,7 +62,7 @@ public class SystemSetFragment extends Fragment implements View.OnClickListener } @Override - public void InfoMsg(String msg,String datetime) { + public void InfoMsg(String msg, String datetime) { BPA_LOG log = new BPA_LOG(); log.userID = ConfigName.getInstance().user.userID; log.createTime = datetime; @@ -68,16 +71,18 @@ public class SystemSetFragment extends Fragment implements View.OnClickListener QueryDB.Addlog(log); Log.i("Info", msg); } + @Override public void WarnMsg(String msg) { Log.w("Warn", msg); } }; - + //默认打开参数设置界面 + ShowFragment(Systemparameter); } - private void initEvent(){ + private void initEvent() { btn_system_set.setOnClickListener(this); btn_lc_set.setOnClickListener(this); } @@ -86,28 +91,24 @@ public class SystemSetFragment extends Fragment implements View.OnClickListener @Override public void onClick(View v) { switch (v.getId()) { - case R.id.stparameter://返回按钮 - Log.d("页面", "onClick: "); + case R.id.stparameter://系統參數設置 + ShowFragment(Systemparameter); + break; + case R.id.lcparameter://料倉設置 + ShowFragment(lcparameter); break; - case R.id.lcparameter://返回按钮 - ShowFragment(lcparameter); - break; - - } } - public void ShowFragment(Fragment fragment) - { + public void ShowFragment(Fragment fragment) { FragmentManager manager = getChildFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); - if(SelectFragment!=null) - { + if (SelectFragment != null) { transaction.remove(SelectFragment); } transaction.add(R.id.fragment_container, fragment); transaction.commit(); - SelectFragment=fragment; + SelectFragment = fragment; } } \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/fragment/setting/systemparameter.java b/app/src/main/java/com/example/bpa/view/fragment/setting/systemparameter.java index fb07369..01bca59 100644 --- a/app/src/main/java/com/example/bpa/view/fragment/setting/systemparameter.java +++ b/app/src/main/java/com/example/bpa/view/fragment/setting/systemparameter.java @@ -1,16 +1,186 @@ package com.example.bpa.view.fragment.setting; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import android.os.Build; import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.EditText; import com.example.bpa.R; +import com.example.bpa.app.DeviceData; +import com.example.bpa.config.ConfigName; +import com.example.bpa.db.QueryDB; +import com.example.bpa.db.mode.BPA_GOODS; +import com.example.bpa.db.mode.BPA_SYSTEMSET; +import com.example.bpa.helper.T; -public class systemparameter extends AppCompatActivity { +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +public class systemparameter extends Fragment implements View.OnClickListener{ + + //region 界面变量 + /** + * 界面实例 + */ + private View view; + /** + * 输入变量 + */ + EditText passwayText_1,passwayText_2,passwayText_3,passwayText_4,passwayText_5,passwayText_6,passwayText_7,passwayText_8,passwayText_9,passwayText_10; + /** + * 保存参数设置 + */ + Button SaveButton; + /** + * 系统设置参数 + */ + ArrayList bpa_systemsets=new ArrayList<>(); + + List editTextLists = new ArrayList(); + //endregion + + //region 私有函数 @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_systemparameter); + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + view = inflater.inflate(R.layout.activity_systemparameter, container,false); + Init(); + initEvents(); + Initdata(); + return view; + } + //endregion + + //region 公有函数 + + /** + * 初始化 + */ + public void Init() + { + passwayText_1 = view.findViewById(R.id.passwayText_1); + passwayText_2 = view.findViewById(R.id.passwayText_2); + passwayText_3 = view.findViewById(R.id.passwayText_3); + passwayText_4 = view.findViewById(R.id.passwayText_4); + passwayText_5 = view.findViewById(R.id.passwayText_5); + passwayText_6 = view.findViewById(R.id.passwayText_6); + passwayText_7 = view.findViewById(R.id.passwayText_7); + passwayText_8 = view.findViewById(R.id.passwayText_8); + passwayText_9 = view.findViewById(R.id.passwayText_9); + editTextLists = Arrays.asList(passwayText_1,passwayText_2,passwayText_3,passwayText_4,passwayText_5,passwayText_6,passwayText_7,passwayText_8,passwayText_9); + //保存按钮 + SaveButton = view.findViewById(R.id.StartButton); + } + /** + * 初始化按钮事件 + */ + private void initEvents() + { + SaveButton.setOnClickListener(this); + } + + /** + * 初始化数据加载 + */ + public void Initdata() { + bpa_systemsets=QueryDB.GetSystemsetALL(); + for (BPA_SYSTEMSET item:bpa_systemsets) + { + switch (item.type) + { + case 1: + ConfigName.getInstance().OrderPushTime=Integer.parseInt(item.value); + passwayText_1.setText(item.value); + break; + case 2: + ConfigName.getInstance().SilosValuePushTime=Integer.parseInt(item.value); + passwayText_2.setText(item.value); + break; + case 3: + ConfigName.getInstance().OtherValuePushTime=Integer.parseInt(item.value); + passwayText_3.setText(item.value); + + break; + case 4: + ConfigName.getInstance().PipeDrainCycleTime=Integer.parseInt(item.value); + passwayText_4.setText(item.value); + break; + case 5: + ConfigName.getInstance().OrderTimeout=Integer.parseInt(item.value); + passwayText_5.setText(item.value); + break; + case 6: + ConfigName.getInstance().SiloFeedThreshold=Integer.parseInt(item.value); + passwayText_6.setText(item.value); + break; + case 7: + ConfigName.getInstance().SiloAlarmThreshold=Integer.parseInt(item.value); + passwayText_7.setText(item.value); + break; + case 8: + ConfigName.getInstance().AICleanTime=Integer.parseInt(item.value); + passwayText_8.setText(item.value); + break; + case 9: + ConfigName.getInstance().AutKey=item.value; + passwayText_9.setText(item.value); + break; + case 10: + break; + case 11: + break; + + } + + } + } + //endregion + + //region 界面点击事件 + /** + * 本页面点击事件监听22 + * + * @param v + */ + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.StartButton://保存参数 + ConfigName.getInstance().OrderPushTime=Integer.parseInt(passwayText_1.getText().toString()); + ConfigName.getInstance().SilosValuePushTime=Integer.parseInt(passwayText_2.getText().toString()); + ConfigName.getInstance().OtherValuePushTime=Integer.parseInt(passwayText_3.getText().toString()); + ConfigName.getInstance().PipeDrainCycleTime=Integer.parseInt(passwayText_4.getText().toString()); + ConfigName.getInstance().OrderTimeout=Integer.parseInt(passwayText_5.getText().toString()); + ConfigName.getInstance().SiloFeedThreshold=Integer.parseInt(passwayText_6.getText().toString()); + ConfigName.getInstance().SiloAlarmThreshold=Integer.parseInt(passwayText_7.getText().toString()); + ConfigName.getInstance().AICleanTime=Integer.parseInt(passwayText_8.getText().toString()); + ConfigName.getInstance().AutKey=passwayText_9.getText().toString(); + + for (BPA_SYSTEMSET item:bpa_systemsets) + { + QueryDB.DeleteSystemset(item.id); + } + for (int i = 0; i - + tools:context=".view.fragment.setting.systemparameter"> + + + + + + + + + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +