diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4bc15681..0e8d345d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,9 @@ tools:ignore="GoogleAppIndexingWarning" tools:node="merge" tools:replace="android:icon"> + diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java index 91cb02b5..434154d6 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -825,6 +825,8 @@ public class ExecuteTheRecipe { WritePLC("初始化",false,null); ExecuteTheRecipe.WritePLC("温控开关", false, null);//开关闭合 + ExecuteTheRecipe.WritePLC("暂停开关", false, null);//开关闭合 + } catch (InterruptedException e) { ToastUtils.info("异常信息:" + e.getMessage()); } diff --git a/app/src/main/java/com/bonait/bnframework/business/MainInit.java b/app/src/main/java/com/bonait/bnframework/business/MainInit.java index 89c58b01..c524be0a 100644 --- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java +++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java @@ -190,9 +190,31 @@ public class MainInit { user.account = "admin"; user.pass = "123456"; user.deviceID = ConfigName.getInstance().DeviceId; - user.userID = "20230415-fyf"; + user.userID = "超级管理员"; user.exp = "管理员"; QueryDB.AddUser(user); + + BPA_USER user1 = new BPA_USER(); + user1.name = "一般用户"; + user1.account = "ybyh"; + user1.pass = "123456"; + user1.deviceID = ConfigName.getInstance().DeviceId; + user1.userID = "一般用户"; + user1.exp = "一般用户"; + QueryDB.AddUser(user1); + + + BPA_USER user2 = new BPA_USER(); + user2.name = "研发用户"; + user2.account = "yfyh"; + user2.pass = "123456"; + user2.deviceID = ConfigName.getInstance().DeviceId; + user2.userID = "研发用户"; + user2.exp = "研发用户"; + QueryDB.AddUser(user2); + + + //10个料仓 if (QueryDB.GetSilosALL().size() == 0) { for (int i = 0; i < 5; i++) { diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index 6690a5dc..c0c21c02 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -252,6 +252,7 @@ public class ConfigName { add(new Res_PLCADDRESS("加热", "M10.6", 0, 1)); add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1)); add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1)); + add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1)); //主料 add(new Res_PLCADDRESS("主料", "M17.4", 0, 1)); @@ -402,6 +403,7 @@ public class ConfigName { add(new Res_PLCADDRESS("加热", "M10.6", 0, 1)); add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1)); add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1)); + add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1)); //主料 add(new Res_PLCADDRESS("主料", "M17.4", 0, 1)); @@ -611,6 +613,7 @@ public class ConfigName { add(new Res_PLCADDRESS("加热", "M10.6", 0, 1)); add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1)); add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1)); + add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1)); //主料 add(new Res_PLCADDRESS("主料", "M17.4", 0, 1)); @@ -996,4 +999,12 @@ public class ConfigName { */ public String versionSelectionEnum = "大炒版本"; //endregion + + //region 用户角色 + public List UserRole = new ArrayList() {{ + add("一般用户"); + add("研发用户"); + add("超级管理员"); + }}; + //eneregion } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java index e1bcd4cf..f9f96e6c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java @@ -4,6 +4,7 @@ import android.content.ContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.util.Log; +import android.widget.TableRow; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.file.DBHelper; @@ -1740,6 +1741,23 @@ public class QueryDB { /** * ID查询用户 * + * @param + * @return + */ + public static boolean GetUserIsCZ(String account,String name) { + String orderby = Desc_Time_Up;//先按排序 创建时间倒序 + String where = "isDelete=? and (account=? or name=?)"; + String[] args = new String[]{"0", account, name}; + ArrayList data = new ArrayList<>(); + ArrayList obj = Get(BPA_USER.class, where, args, orderby); + for (Object k : obj) { + data.add((BPA_USER) k); + } + return data.size()>0; + } + /** + * 判断用户名称是否存在 + * * @param id * @return */ @@ -1758,8 +1776,8 @@ public class QueryDB { Log.d("ID查询用户信息", "ID查询用户信息异常: " + e.getMessage()); return null; } - } + /** * 修改签名 * @param id @@ -1786,6 +1804,22 @@ public class QueryDB { } return user; } + + /** + * 修改用户名 + * + * @param id + * @param data + */ + public static BPA_USER UpdateAccount(String id, String data) { + BPA_USER user = GetUserID(id); + if (user != null) { + user.account = data; + Update(BPA_USER.class, user); + } + return user; + } + /** * 修改密码 * @param id @@ -1799,6 +1833,20 @@ public class QueryDB { } return user; } + + /** + * 修改权限 + * @param id + * @param data + */ + public static BPA_USER UpdateUserRole(String id, String data) { + BPA_USER user = GetUserID(id); + if (user != null) { + user.userID = data; + Update(BPA_USER.class, user); + } + return user; + } //endregion //region BPA_MENU 菜单表 diff --git a/app/src/main/java/com/bonait/bnframework/common/view/AddUserDialog.java b/app/src/main/java/com/bonait/bnframework/common/view/AddUserDialog.java new file mode 100644 index 00000000..f0f3f7fd --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/view/AddUserDialog.java @@ -0,0 +1,241 @@ +package com.bonait.bnframework.common.view; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.os.Bundle; +import android.text.TextUtils; +import android.view.View; +import android.view.ViewGroup; +import android.view.WindowManager; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.TextView; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.model.mode.BomTypeInfo; +import com.bonait.bnframework.common.model.mode.FoodMenuInfo; +import com.bonait.bnframework.common.model.mode.GoodsParentTypeInfo; +import com.bonait.bnframework.common.model.mode.GoodsTypeInfo; +import com.bonait.bnframework.common.model.mode.GoodsUintInfo; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class AddUserDialog extends Dialog { + private Button yes, no;//确定按钮 + + //用户名称 账户名称 用户密码 再次确认密码 用户角色 + private EditText edittext, edittext1, edittext2, edittext3, edittext4; + + //确定文本和取消文本的显示内容 + private String yesStr, noStr; + + private onNoOnclickListener noOnclickListener;//取消按钮被点击了的监听器 + private onYesOnclickListener yesOnclickListener;//确定按钮被点击了的监听器 + + /** + * 设置取消按钮的显示内容和监听 + * + * @param str + * @param onNoOnclickListener + */ + public void setNoOnclickListener(String str, onNoOnclickListener onNoOnclickListener) { + if (str != null) { + noStr = str; + } + this.noOnclickListener = onNoOnclickListener; + } + + /** + * 设置确定按钮的显示内容和监听 + * + * @param str + * @param onYesOnclickListener + */ + public void setYesOnclickListener(String str, onYesOnclickListener onYesOnclickListener) { + if (str != null) { + yesStr = str; + } + this.yesOnclickListener = onYesOnclickListener; + } + + public AddUserDialog(Context context) { + super(context, R.style.Dialog_Msg); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.dialog_user); + //按空白处不能取消动画 + setCanceledOnTouchOutside(false); + + //初始化界面控件 + initView(); + //初始化界面数据 + initData(); + //初始化界面控件的事件 + initEvent(); + + } + + /** + * 初始化界面的确定和取消监听器 + */ + private void initEvent() { + //设置确定按钮被点击后,向外界提供监听 + yes.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (DataVerification()) { + if (yesOnclickListener != null) { + yesOnclickListener.onYesClick( + edittext.getText().toString() + , edittext1.getText().toString() + , edittext2.getText().toString() + , edittext4.getText().toString() + ); + } + } + } + }); + + no.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (noOnclickListener != null) { + noOnclickListener.onNoClick(); + } + } + }); + + edittext4.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + checkboxEdit(edittext4); + } + }); + } + + /** + * 多选下拉框 + */ + private void checkboxEdit(EditText edit) { + final String[] items = ConfigName.getInstance().UserRole.toArray(new String[0]); + final int checkIndex = 0; + new QMUIDialog.CheckableDialogBuilder(getContext()) + .addItems(items, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + edit.setText(items[which]); + dialog.dismiss(); + } + }) + .setCheckedIndex(checkIndex) + .show(); + } + + /** + * 初始化界面控件的显示数据 + */ + private void initData() { + //如果设置按钮的文字 + if (yesStr != null) { + yes.setText(yesStr); + } + } + + /** + * 初始化界面控件 + */ + private void initView() { + yes = (Button) findViewById(R.id.yes); + no = (Button) findViewById(R.id.no); + edittext = (EditText) findViewById(R.id.edittext); + edittext1 = (EditText) findViewById(R.id.edittext1); + edittext2 = (EditText) findViewById(R.id.edittext2); + edittext3 = (EditText) findViewById(R.id.edittext3); + edittext4 = (EditText) findViewById(R.id.edittext4); + + } + + /** + * 数据验证 + * + * @return + */ + public boolean DataVerification() { + boolean IsSucees = false; + try { + if (edittext.getText().toString().isEmpty()) { + ToastUtils.info("用户名称不能为空!"); + return false; + } + if (edittext1.getText().toString().isEmpty()) { + ToastUtils.info("账户名称不能为空!"); + return false; + } + if (edittext2.getText().toString().isEmpty()) { + ToastUtils.info("用户密码不能为空!"); + return false; + } + if (edittext3.getText().toString().isEmpty()) { + ToastUtils.info("用户密码不能为空!"); + return false; + } + + if (!edittext3.getText().toString().equals(edittext2.getText().toString())) { + ToastUtils.info("两次密码输入不一致!"); + return false; + } + if (edittext4.getText().toString().isEmpty()) { + ToastUtils.info("用户角色不能为空!"); + return false; + } + return true; + } catch (Exception ex) { + ToastUtils.error("数据验证异常!" + ex.getMessage()); + return IsSucees; + } + } + + public void SetAdapter(Spinner spinner, Map map) { + ArrayAdapter adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(map.keySet())); + adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + spinner.setAdapter(adapter); + } + + /** + * 设置确定按钮和取消被点击的接口 + */ + public interface onYesOnclickListener { + public void onYesClick(String name, String acc, String pass, String qx); + } + + public interface onNoOnclickListener { + public void onNoClick(); + } + + @Override + public void show() { + super.show(); + /** + * 设置宽度全屏,要设置在show的后面 + */ + WindowManager.LayoutParams layoutParams = getWindow().getAttributes(); + layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; + layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; + getWindow().getDecorView().setPadding(0, 0, 0, 0); + getWindow().setAttributes(layoutParams); + } +} + diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/user_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/user_adapter.java new file mode 100644 index 00000000..8a540afb --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/user_adapter.java @@ -0,0 +1,93 @@ +package com.bonait.bnframework.modules.home.adapter; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_USER; +import com.bonait.bnframework.common.helper.I.MyClickListener; + +import java.util.List; + +public class user_adapter extends ArrayAdapter { + /** + * 内部点击事件 + */ + private MyClickListener mListener; + private List datas; + int resource1; + public user_adapter(@NonNull Context context, int resource, @NonNull List objects, MyClickListener listener) { + super(context, resource, objects); + mListener = listener; + datas=objects; + this.resource1=resource; + } + //每个子项被滚动到屏幕内的时候会被调用 + @NonNull + @Override + public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { + BPA_USER bpa_material = (BPA_USER) getItem(position);//得到当前项选中item实例 + //为每一个子项加载设定的布局 + View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); + //分别获取 image view 和 textview 的实例 + TextView name = view.findViewById(R.id.name); + TextView zhanghao = view.findViewById(R.id.zhanghao); + TextView mima = view.findViewById(R.id.mima); + TextView quanxian = view.findViewById(R.id.quanxian); + + Button button = view.findViewById(R.id.button_item); + + // 设置要显示的图片和文字 + name.setText(bpa_material.name+""); + zhanghao.setText(bpa_material.account+""); + mima.setText(bpa_material.pass+""); + quanxian.setText(bpa_material.userID+""); + name.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bpa_material); + } + }); + + zhanghao.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bpa_material); + } + }); + + mima.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bpa_material); + } + }); + + quanxian.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bpa_material); + } + }); + + + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(mListener!=null) mListener.clickListener(view,bpa_material); + } + }); + + + return view; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java index c04dd214..c45bce8a 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java @@ -64,6 +64,8 @@ public class MyFragment extends BaseFragment { @BindView(R.id.stv_huifu) SuperTextView stv_huifu; + @BindView(R.id.stv_user) + SuperTextView stv_user; @BindView(R.id.stv_announcement) SuperTextView stvAnnouncement; @@ -153,6 +155,18 @@ public class MyFragment extends BaseFragment { skipToNoticeActivity(); } }); + /** + * 用户管理 + */ + stv_user.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() { + @Override + public void onClickListener(SuperTextView superTextView) { + Intent intent = new Intent(context, UserActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + }); + /** * 用户名点击 */ @@ -173,6 +187,13 @@ public class MyFragment extends BaseFragment { .addAction("确定", new QMUIDialogAction.ActionListener() { @Override public void onClick(QMUIDialog dialog, int index) { + String name = ConfigName.getInstance().user.name; + String ac = ConfigName.getInstance().user.account; + if (name.equals("admin") || ac.equals("admin")) { + ToastUtils.warning("对不起,admin账户禁止操作!"); + return; + } + CharSequence text = builder.getEditText().getText(); if (text != null && text.length() > 0) { BPA_USER user= QueryDB.UpdateUserName(ConfigName.getInstance().user.id,text.toString()); @@ -207,6 +228,13 @@ public class MyFragment extends BaseFragment { .addAction("确定", new QMUIDialogAction.ActionListener() { @Override public void onClick(QMUIDialog dialog, int index) { + String name = ConfigName.getInstance().user.name; + String ac = ConfigName.getInstance().user.account; + if (name.equals("admin") || ac.equals("admin")) { + ToastUtils.warning("对不起,admin账户禁止操作!"); + return; + } + CharSequence text = builder.getEditText().getText(); if (text != null && text.length() > 0) { BPA_USER user= QueryDB.UpdateUserSign(ConfigName.getInstance().user.id,text.toString()); @@ -240,6 +268,13 @@ public class MyFragment extends BaseFragment { .addAction("确定", new QMUIDialogAction.ActionListener() { @Override public void onClick(QMUIDialog dialog, int index) { + String name = ConfigName.getInstance().user.name; + String ac = ConfigName.getInstance().user.account; + if (name.equals("admin") || ac.equals("admin")) { + ToastUtils.warning("对不起,admin账户禁止操作!"); + return; + } + CharSequence text = builder.getEditText().getText(); if (text != null && text.length() > 0) { BPA_USER user= QueryDB.UpdateUserPass(ConfigName.getInstance().user.id,text.toString()); diff --git a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/UserActivity.java b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/UserActivity.java new file mode 100644 index 00000000..11b50edc --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/UserActivity.java @@ -0,0 +1,370 @@ +package com.bonait.bnframework.modules.mine.fragment; + +import androidx.appcompat.app.AppCompatActivity; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.os.Bundle; +import android.text.InputType; +import android.text.TextUtils; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ListView; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseActivity; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; +import com.bonait.bnframework.common.db.mode.BPA_SILOS; +import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_USER; +import com.bonait.bnframework.common.helper.I.IRunT; +import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; +import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.model.ResAPI; +import com.bonait.bnframework.common.model.mode.ActionJsonMode; +import com.bonait.bnframework.common.model.mode.BatchingInfo; +import com.bonait.bnframework.common.model.mode.BomTechnologyActionInfo; +import com.bonait.bnframework.common.model.mode.CloudGood; +import com.bonait.bnframework.common.model.mode.GoodsTechnology; +import com.bonait.bnframework.common.model.mode.TechnologyAction; +import com.bonait.bnframework.common.model.mode.UpdateBomInfo; +import com.bonait.bnframework.common.model.mode.UpdateCloudGood; +import com.bonait.bnframework.common.oss.OssHelper; +import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.common.view.AddUserDialog; +import com.bonait.bnframework.common.view.GoodEditDialog; +import com.bonait.bnframework.modules.home.adapter.user_adapter; +import com.google.gson.Gson; +import com.lzy.okgo.OkGo; +import com.lzy.okgo.model.HttpHeaders; +import com.lzy.okgo.model.Response; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; +import okhttp3.MediaType; +import okhttp3.RequestBody; + +public class UserActivity extends BaseActivity implements MyClickListener { + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + + @BindView(R.id.add_wl) + Button add_wl; + @BindView(R.id.datatab) + ListView datatab; + /** + * 用户数据 + */ + ArrayList bpa_users = new ArrayList<>(); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_user); + //属性绑定 + ButterKnife.bind(this); + initTopBar(); + InitView(); + } + + private void initTopBar() { + mTopBar.setTitle("账户管理"); + mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + } + + /** + * 初始化界面 + */ + public void InitView() { + Initdata(); + } + + @OnClick({R.id.add_wl, R.id.synchronous}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.add_wl://新增用户 + + final AddUserDialog editDialog = new AddUserDialog(this); + editDialog.setTitle("角色列表"); + editDialog.setYesOnclickListener("确定", new AddUserDialog.onYesOnclickListener() { + @Override + public void onYesClick(String name, String acc, String pass, String qx) { + + if (name.toString().equals("admin") || acc.toString().equals("admin")) { + ToastUtils.warning("不能设置账号为admin!"); + return; + } + + BPA_USER bpa_user = new BPA_USER(); + bpa_user.name = name; + bpa_user.account = acc; + bpa_user.pass = pass; + bpa_user.deviceID = ConfigName.getInstance().DeviceId; + bpa_user.userID =qx;//更改为,用户权限 // 一般用户 研发用户 超级管理员 + if(QueryDB.GetUserIsCZ(bpa_user.account,bpa_user.name)) + { + ToastUtils.warning("已有该账户,请重新填写账户信息!"); + return; + } + QueryDB.AddUser(bpa_user); + ToastUtils.info("新增成功"); + Initdata(); + editDialog.dismiss(); + } + }); + editDialog.setNoOnclickListener("取消", new AddUserDialog.onNoOnclickListener() { + @Override + public void onNoClick() { + editDialog.dismiss(); + } + }); + editDialog.show(); + break; + + case R.id.synchronous://新增用户 + + String title = "温馨提示!"; + String message = "客官确定要恢复出厂账户吗?"; + AlertDialogUtils.showDialog(this, title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + ArrayList users=QueryDB.GetUserALL(); + for (BPA_USER item:users) + { + QueryDB.DeleteUser(item); + } + BPA_USER user = new BPA_USER(); + user.id = "20230415-fyf"; + user.name = "管理员"; + user.account = "admin"; + user.pass = "123456"; + user.deviceID = ConfigName.getInstance().DeviceId; + user.userID = "超级管理员"; + user.exp = "管理员"; + QueryDB.AddUser(user); + + BPA_USER user1 = new BPA_USER(); + user1.name = "一般用户"; + user1.account = "ybyh"; + user1.pass = "123456"; + user1.deviceID = ConfigName.getInstance().DeviceId; + user1.userID = "一般用户"; + user1.exp = "一般用户"; + QueryDB.AddUser(user1); + + + BPA_USER user2 = new BPA_USER(); + user2.name = "研发用户"; + user2.account = "yfyh"; + user2.pass = "123456"; + user2.deviceID = ConfigName.getInstance().DeviceId; + user2.userID = "研发用户"; + user2.exp = "研发用户"; + QueryDB.AddUser(user2); + + ToastUtils.info("恢复出厂成功!"); + Initdata(); + dialog.dismiss(); + } + }); + break; + } + } + + + /** + * 初始化数据加载 + */ + public void Initdata() { + try { + bpa_users = QueryDB.GetUserALL(); + user_adapter adapter = new user_adapter(getBaseContext(), R.layout.user_item, bpa_users, this); + datatab.setAdapter(adapter); + } catch (Exception e) { + + } + } + + @Override + public void clickListener(View v, Object data) { + String name = ((BPA_USER) data).name; + String ac = ((BPA_USER) data).account; + if (name.equals("admin") || ac.equals("admin")) { + ToastUtils.warning("对不起,admin账户禁止操作!"); + return; + } + switch (v.getId()) { + case R.id.name://修改物料名称按钮 + final QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(this); + builder.setTitle("用户名称") + .setPlaceholder("在此输入用户名称") + .setDefaultText(((BPA_USER) data).name) + .setInputType(InputType.TYPE_CLASS_TEXT) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder.getEditText().getText(); + if (text != null && text.length() > 0) { + if (text.toString().equals("admin")) { + ToastUtils.warning("不能设置账号为admin!"); + return; + } + + if(QueryDB.GetUserIsCZ(((BPA_USER) data).account,text.toString())) + { + ToastUtils.warning("已有该账户,请重新填写账户信息!"); + return; + } + QueryDB.UpdateUserName(((BPA_USER) data).id, text.toString()); + Initdata(); + ToastUtils.info("修改成功"); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.warning("不能为空!"); + } + } + }) + .show(); + break; + case R.id.zhanghao://修改物料名称按钮 + final QMUIDialog.EditTextDialogBuilder builder1 = new QMUIDialog.EditTextDialogBuilder(this); + builder1.setTitle("用户账号") + .setPlaceholder("在此输入用户账号") + .setDefaultText(((BPA_USER) data).account) + .setInputType(InputType.TYPE_CLASS_TEXT) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder1.getEditText().getText(); + if (text != null && text.length() > 0) { + if (text.toString().equals("admin")) { + ToastUtils.warning("不能设置账号为admin!"); + return; + } + if(QueryDB.GetUserIsCZ(text.toString(),((BPA_USER) data).name)) + { + ToastUtils.warning("已有该账户,请重新填写账户信息!"); + return; + } + + QueryDB.UpdateAccount(((BPA_USER) data).id, text.toString()); + Initdata(); + ToastUtils.info("修改成功"); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("不能为空!"); + } + } + }) + .show(); + break; + case R.id.mima://修改物料名称按钮 + final QMUIDialog.EditTextDialogBuilder builder2 = new QMUIDialog.EditTextDialogBuilder(this); + builder2.setTitle("用户密码") + .setPlaceholder("在此输入用户密码") + .setDefaultText(((BPA_USER) data).pass) + .setInputType(InputType.TYPE_CLASS_TEXT) + .addAction("取消", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + dialog.dismiss(); + } + }) + .addAction("确定", new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + CharSequence text = builder2.getEditText().getText(); + if (text != null && text.length() > 0) { + QueryDB.UpdateUserPass(((BPA_USER) data).id, text.toString()); + Initdata(); + ToastUtils.info("修改成功"); + dialog.dismiss(); + } else { + //请填入昵称 + ToastUtils.info("不能为空!"); + } + } + }) + .show(); + break; + + case R.id.quanxian://修改物料名称按钮 + final String [] items=ConfigName.getInstance().UserRole.toArray(new String[0]); + int checkIndex=1; + String qx=((BPA_USER) data).userID; + for (int k=0;k + + + + + + + + + + + + + + + + + + +