@@ -8,6 +8,8 @@ import android.widget.Button; | |||
import android.widget.EditText; | |||
import com.example.bpa.app.Main; | |||
import com.example.bpa.config.ConfigName; | |||
import com.example.bpa.db.QueryDB; | |||
import com.example.bpa.db.mode.BPA_USER; | |||
import com.example.bpa.helper.T; | |||
public class LoginActivity extends Activity implements View.OnClickListener { | |||
@@ -36,8 +38,8 @@ public class LoginActivity extends Activity implements View.OnClickListener { | |||
username = findViewById(R.id.input_layout_name); | |||
password = findViewById(R.id.input_layout_psw); | |||
btn_login = findViewById(R.id.btn_login); | |||
username.setText(ConfigName.getInstance().username); | |||
password.setText(ConfigName.getInstance().password); | |||
username.setText(ConfigName.getInstance().user.account ); | |||
password.setText(ConfigName.getInstance().user.pass ); | |||
} | |||
/** | |||
* 初始化按钮事件 | |||
@@ -54,10 +56,10 @@ public class LoginActivity extends Activity implements View.OnClickListener { | |||
{ | |||
String inputName = username.getText().toString(); | |||
String pwd = password.getText().toString(); | |||
if (inputName.equals("admin") && pwd.equals("123456")) { | |||
ConfigName.getInstance().username = inputName; | |||
ConfigName.getInstance().password = pwd; | |||
BPA_USER user= QueryDB.UserLogin(inputName,pwd); | |||
if (user!=null) { | |||
Main.getInstance().SavePZ();//保存配置 | |||
ConfigName.getInstance().user = user; | |||
T.show(LoginActivity.this, "登录成功!"); | |||
try { | |||
Intent intent = new Intent(LoginActivity.this, MainActivity.class); | |||
@@ -7,6 +7,7 @@ import android.util.Log; | |||
import com.example.bpa.config.ConfigName; | |||
import com.example.bpa.db.QueryDB; | |||
import com.example.bpa.db.mode.BPA_MATERIAL; | |||
import com.example.bpa.db.mode.BPA_USER; | |||
import com.example.bpa.helper.Json; | |||
import com.example.bpa.helper.SdCart; | |||
import com.example.bpa.helper.ToastUtil; | |||
@@ -28,6 +29,28 @@ public class ICSApp extends Application { | |||
Main.getInstance(); | |||
//2.初始化SD卡,数据库DB | |||
SdCart.getInstance().initSD(); | |||
//3.初始化数据 | |||
InitDBdata(); | |||
} | |||
/** | |||
* 初始化数据库数据 | |||
*/ | |||
public void InitDBdata() | |||
{ | |||
//1.没有用户数据 默认写一个admin | |||
if(QueryDB.GetUserALL().size()<=0) | |||
{ | |||
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="20230415-fyf"; | |||
user.exp="管理员"; | |||
QueryDB.AddUser(user); | |||
} | |||
} | |||
/** | |||
@@ -63,5 +86,4 @@ public class ICSApp extends Application { | |||
} | |||
} |
@@ -47,8 +47,8 @@ public class Main { | |||
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().username = ConfigUtil.read(ConfigName.getInstance().dishesCon, "username", ConfigName.getInstance().username); | |||
ConfigName.getInstance().password = ConfigUtil.read(ConfigName.getInstance().dishesCon, "password", ConfigName.getInstance().password); | |||
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); | |||
} | |||
/** | |||
@@ -60,8 +60,8 @@ public class Main { | |||
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().username); | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"password", ConfigName.getInstance().password); | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"username", ConfigName.getInstance().user.account); | |||
ConfigUtil.write(ConfigName.getInstance().dishesCon,"password", ConfigName.getInstance().user.pass); | |||
} | |||
//endregion | |||
} |
@@ -2,6 +2,8 @@ package com.example.bpa.config; | |||
import android.content.Context; | |||
import com.example.bpa.db.mode.BPA_USER; | |||
/** | |||
* 配置文件 | |||
*/ | |||
@@ -48,16 +50,51 @@ public class ConfigName { | |||
* 店铺设备号 | |||
*/ | |||
public String AutKey="95"; | |||
/** | |||
* 店铺设备号 | |||
*/ | |||
public String DeviceId="20020415-test"; | |||
//endregion | |||
//region 登录信息 | |||
/** | |||
* 用户名称 | |||
* 用户信息 | |||
*/ | |||
public BPA_USER user=new BPA_USER(); | |||
//endregion | |||
//region 系统设置表 | |||
/** | |||
* 订单上报周期,默认一小时 *60 | |||
*/ | |||
public int OrderPushTime=3600; | |||
/** | |||
* 料仓余量上报周期,默认10分钟 *60 | |||
*/ | |||
public int SilosValuePushTime=600; | |||
/** | |||
* 其他传感器上报周期,默认10分钟 *60 | |||
*/ | |||
public int OtherValuePushTime=600; | |||
/** | |||
* 管道排空周期,默认一小时 *60 | |||
*/ | |||
public int PipeDrainCycleTime=3600; | |||
/** | |||
* 订单未制作超时规则,默认20分钟 *60 | |||
*/ | |||
public int OrderTimeout=1200; | |||
/** | |||
* 料仓补料阈值,500g | |||
*/ | |||
public int SiloFeedThreshold=500; | |||
/** | |||
* 料仓告警阈值,50g | |||
*/ | |||
public String username=""; | |||
public int SiloAlarmThreshold=50; | |||
/** | |||
* 密码 | |||
* 自动清洗时间,默认一小时 *60 | |||
*/ | |||
public String password=""; | |||
public int AICleanTime=3600; | |||
//endregion | |||
} |
@@ -797,6 +797,27 @@ public class QueryDB { | |||
} | |||
return data; | |||
} | |||
/** | |||
* 用户登录 | |||
* @param Name | |||
* @param Pass | |||
* @return | |||
*/ | |||
public static BPA_USER UserLogin(String Name,String Pass) | |||
{ | |||
String orderby=Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where="isDelete=? and (account=? or name=?) and pass=?"; | |||
String[] args=new String[] { "0",Name,Name,Pass }; | |||
ArrayList<BPA_USER> data=new ArrayList<>(); | |||
ArrayList<Object> obj=Get(BPA_USER.class,where,args,orderby); | |||
for (Object k:obj) { | |||
data.add((BPA_USER)k); | |||
} | |||
if(data.size()<=0) | |||
return null; | |||
else | |||
return data.get(0); | |||
} | |||
//endregion | |||
//region BPA_MENU 菜单表 | |||
@@ -33,6 +33,7 @@ public class ModeBase { | |||
{ | |||
id=java.util.UUID.randomUUID().toString(); | |||
createTime= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());; | |||
isDelete=0; | |||
//Log.i("日志","创建时间:"+ createTime); | |||
} | |||
} |